Henglos IO
Built-in packages

HTTP

Calls web APIs from the board — Request a URL (GET, POST…) with headers, a body and an auth token; the whole answer lands in a file the next actions read (Read JSON, the Filesystem component), and Pick takes one value out of its JSON right away.

Calls web APIs from the board — Request a URL (GET, POST…) with headers, a body and an auth token; the whole answer lands in a file the next actions read (Read JSON, the Filesystem component), and Pick takes one value out of its JSON right away. And serves them: Request Trigger runs a branch when a request comes in (a webhook), Respond answers it. Needs a network: WiFi's Connect before it.

@henglosio/component-httpv1.0.0platform ^1.0.0needswifi
NodeKindWhat it does
Request TriggerTriggerRuns its branch when a request comes in on Port for Method under Path — a webhook, a page's button, another board.
RequestActionCalls a URL — goes on (Out) on a 2xx answer, Fallback when there's no network, it took longer than Timeout, or the server answered 4xx/5xx (error says which).
Read JSONActionOne value from a JSON file on the board — a Request's file (bind it), or any other.
RespondActionAnswers the request its Request Trigger's branch runs for — Status and a Body (or a File).

Triggers

Request Trigger

Runs its branch when a request comes in on Port for Method under Path — a webhook, a page's button, another board. Answer it with Respond; a branch that doesn't answers 200. A path outside it gets 404, another method 405, a request without Auth's header 401. Needs WiFi (Connect on Start).

A trigger: no input, one Out — the first action of its branch.

Settings

SettingTypeDefaultWhat it's for
PathText/webhookRequired. The base path it answers under — /api takes /api and everything below it (/api/led/on), read in subpath and segments; / takes every path. Two triggers on one port: the longer base path wins. The query (?a=1) doesn't count.
MethodOne of: Any, GET, POST, PUT, PATCH, DELETEAnyWhich requests run it — Any, or only one method.
PortNumber (1 to 65535)80The port the board listens on — 80 is plain http://<board ip>/.
PickText—One value from the body's JSON, by its path — sensor.temp, items.0; empty picks nothing. Published as value.
AuthCredential (http_header)—An HTTP Header Auth credential the request must carry (that header, that value) — else 401. Empty lets anyone in.
Save ToText—Advanced. A file of your own for the body — /data/last.json; it stays. Empty, it goes to a temporary file (one per trigger), cleared when a session starts.

Publishes

OutputTypeWhat it is
methodstrThe request's method — GET, POST…
pathstrThe path it came for, without the query.
subpathstrWhat came after the base path — /led/on for /api/led/on on /api; empty for the base itself.
segmentslist of strThe subpath's parts, in order — ["led", "on"]; route on them with a Switch (segments[0]).
queryanyThe query's fields as an object — ?led=on&level=3 is { "led": "on", "level": "3" }.
valueanyWhat Pick found in the body — a number, true/false, text, or a list/object as JSON; empty when nothing was picked.
filestrThe file holding the body — bind it to Read JSON or Filesystem's Read; empty when there was none.
sizeintHow many bytes the body had.
clientstrThe address it came from — 192.168.0.12.
errorstrWhat Pick missed, or why the body couldn't be saved; empty when all went well.

Actions

Request

Calls a URL — goes on (Out) on a 2xx answer, Fallback when there's no network, it took longer than Timeout, or the server answered 4xx/5xx (error says which). The board waits for the answer meanwhile.

Settings

SettingTypeDefaultWhat it's for
MethodOne of: GET, POST, PUT, PATCH, DELETE, HEADGETWhat the request does — GET reads, POST sends, PUT/PATCH change, DELETE removes.
URLText—Required. The address to call — https:// or http:// (without one, http://).
BodyText—What POST, PUT and PATCH send — JSON, form fields or text. GET, HEAD and DELETE send none.
PickText—One value from the JSON answer, by its path — main.temp, weather.0.description (a number steps into a list); empty picks nothing. Published as value.
AuthCredential (http_header)—An HTTP Header Auth credential — the API key or token sent as a header. Empty sends none.
HeadersList of { name: str, value: str }, up to 8[]Advanced. Headers to send — a name and a value each.
Content TypeOne of: Auto, JSON, Form, TextAutoAdvanced. What the Body is — Auto takes JSON when it starts with { or [, text otherwise. A Content-Type in Headers wins.
Save ToText—Advanced. A file of your own for the answer — /data/weather.json, its folders made; it stays. Empty, it goes to a temporary file, cleared when a session starts.
TimeoutNumber (1000 to 60000)10000Advanced. How long it waits for the server, in ms — 1000 to 60000.

Publishes

OutputTypeWhat it is
statusintThe HTTP status — 200 OK, 404 not found, 500 server error…; 0 when no answer came.
valueanyWhat Pick found — a number, true/false, text, or a list/object as JSON; empty when nothing was picked.
filestrThe file holding the whole answer, as text — bind it to Read JSON, Filesystem's Read, or open() it in a Code binding; empty for HEAD or when it failed.
sizeintHow many bytes the answer had.
errorstrWhy it went Fallback, or what Pick missed — no_network, dns, timeout, refused, unreachable, http_404…, "pick: no field temp"; empty when all went well.

Read JSON

One value from a JSON file on the board — a Request's file (bind it), or any other. Fallback when the file isn't there, isn't JSON, or has nothing at Pick.

Settings

SettingTypeDefaultWhat it's for
FileText—Required. The file to read — bind a Request's file, or a path like /data/response.json.
PickText—The value's path — main.temp, weather.0.description; empty takes the whole file (if it fits).

Publishes

OutputTypeWhat it is
valueanyWhat Pick found — a number, true/false, text, or a list/object as JSON.
errorstrWhy it's Fallback — no_file, not_json, no field temp, value_too_large; empty otherwise.

Respond

Answers the request its Request Trigger's branch runs for — Status and a Body (or a File). Fallback when there's none to answer: not in a Request Trigger's branch, or it was answered already.

Settings

SettingTypeDefaultWhat it's for
StatusNumber (100 to 599)200The HTTP status — 200 OK, 201 created, 400 bad request, 404 not found…
BodyText—What it answers — text, or bind a list/object (sent as JSON).
Content TypeOne of: Auto, JSON, Text, HTMLAutoAdvanced. What the Body is — Auto takes JSON for a list/object or text starting with { or [, plain text otherwise.
FileText—Advanced. A file on the board to answer with instead of Body — /www/index.html. Empty sends Body.

Publishes

OutputTypeWhat it is
errorstrWhy it went Fallback — no_request, no_file; empty otherwise.

Credentials

HTTP Header Auth

A header sent with each request — an API key or a bearer token, kept out of the workflow.

FieldWhat it's for
HeaderThe header's name — empty sends Authorization.
ValueThe header's value — "Bearer <token>", an API key…

On this page