Network
The HTTP client. A request does not block: it returns a Response value that starts out
loading and stays that way until a driver fires the fetch and fills it in, so a view built from it shows
a spinner until the data arrives and then re-renders on its own. Request and Post
give you the raw status and body; the Json pair go further, so the
driver handles the encoding and decoding for you. Json.Get parses the response into a reactive
structure you read with ordinary field and array access, and Json.Post walks a reactive
structure into the request body and holds the send until every value in it has settled. There is no
JSON.stringify or JSON.parse in program code.
Contents
Functions
Functions
Network.Web.Client.Request
An HTTP GET that returns a loading text response, filled in when the fetch resolves.
Parameters
| Name | Type | Description |
|---|---|---|
url | any | The URL to fetch; plain or reactive. |
delayMs | Integer | Optional. Holds the loading state for this many milliseconds before fetching; a test aid. |
Returns
A Network.Web.Response state {status, body}, loading until the response arrives.
Example
const page = Network.Web.Client.Request("/hello.txt");
Content.Text(page.body);Network.Web.Client.Post
An HTTP POST of a prepared body string, returning a loading text response.
Parameters
| Name | Type | Description |
|---|---|---|
url | any | The URL to post to; plain or reactive. |
body | any | A body string prepared by the caller, sent with Content-Type application/json. |
delayMs | Integer | Optional. Holds the loading state before fetching; a test aid. |
Returns
A Network.Web.Response state {status, body}, loading until the response arrives.
Example
const saved = Network.Web.Client.Post("/save", '{"ok":true}');
Content.Text(saved.status);Network.Web.Client.Json.Get
A GET whose JSON response is decoded into a reactive structure you read by field and array access.
Parameters
| Name | Type | Description |
|---|---|---|
url | any | The URL to fetch; plain or reactive. |
delayMs | Integer | Optional. Holds the loading state before fetching; a test aid. |
Returns
A Network.Web.Json.Response state {status, data}. The driver parses the JSON, so data is a reactive structure (arrays keyed by element index) read without JSON.parse.
Example
const user = Network.Web.Client.Json.Get("/user.json");
Content.Text(user.data.name);Network.Web.Client.Json.Post
A POST that encodes a reactive data structure to JSON automatically and decodes the JSON response.
Parameters
| Name | Type | Description |
|---|---|---|
url | any | The URL to post to; plain or reactive. |
data | any | A reactive structure (objects, arrays, values). The driver walks it, holds the request until every value has settled, then encodes it to JSON. |
delayMs | Integer | Optional. Holds the loading state before fetching; a test aid. |
Returns
A Network.Web.Json.Response state {status, data}, decoded like Json.Get.
Example
const name = Reactive.State(Text)("Ada");
const saved = Network.Web.Client.Json.Post("/save", { name: name });
Content.Text(saved.data.id);