Docs

HTTP

novon.http: requests, responses, limits and the loopback rule.

Requires the http permission.

const res = await novon.http(`http://${host}/status`);                        // GET
const res = await novon.http(`http://${host}/power`, { method: 'POST', body: { on: true } });
const res = await novon.http({ url, method: 'PUT', headers: { Authorization: `Bearer ${token}` }, body: 'raw', timeoutMs: 5000 });

res.ok;        // 2xx
res.status;
res.headers;   // lower-cased keys
res.text();
res.json<{ on: boolean }>();
  • body: a string is sent as-is; an object or array is JSON-encoded with a JSON content type.
  • timeoutMs defaults to 15 s and is capped by the hub at 30 s.
  • Methods: GET, POST, PUT, PATCH, DELETE, HEAD.

Limits

Four concurrent requests per entry, responses up to 1 MiB. A fifth concurrent call waits; a larger body is truncated and reported as an error. See Limits.

What you cannot reach

Loopback and link-local addresses are refused: the hub's own services are unreachable by design. LAN devices and the internet are fine. A request that fails the policy rejects the promise.

Patterns

  • Poll on a timer, not in a loop. setInterval with a sensible period (≥ 1 s; usually tens of seconds), and stop on unloadEntry (timers are cleared for you, but do not start new ones after).
  • Back off on failure. Count consecutive failures and lengthen the interval, mark entities available: false after a few, and available: true on recovery.
  • Keep credentials in ctx.entry.data, never in logs.

On this page