Calls
Call options
Look up an option a call accepts, its default, and the page that explains it.
Every method takes a path and an object of options, such as
api.get("/todos/:id", { params: { id: 1 }, output: Todo }). Use this page
to look an option up. Each row links to the page that explains it in full.
Options
The following table lists every option a call accepts, with what a call without it does:
| Option | What it does | Default |
|---|---|---|
params | Fills in the path's :name segments. Required when the path has any, and not allowed otherwise. See Fill in path parameters. | None. |
query | Builds the query string from an object. See Build a query string. | None. |
headers | Headers for this call. They win over the client's, and over the body's content-type, except on a FormData body. See Set the content type. | The client's headers. |
body | The request body, sent by its type. Only on post, put, patch, del and request, and on sse and ndjson. See Send a body. | None: no body. |
input | A schema that types body and encodes it. A body that doesn't match makes the call die. See Encode the body with a schema, and Upload files for Fetch.multipart. | None: body is sent by its type. |
output | A schema the 2xx body is decoded with. See Read the response. | None: the call succeeds with the HttpClientResponse. |
responseMode | "decoded-and-response" makes the call succeed with [value, response]. See Read the body and the response. | "decoded": the value alone. |
error | A schema for the body of error responses, decoded onto HttpError.body. See Catch errors. | The client's defaultError, else Schema.Unknown: the parsed JSON. |
statusErrors | Your own errors for error responses, by status. Tried before the client's. See Errors by status. | None: only the client's apply. |
plugins | Turns a plugin off, or changes its options, for this call. See Change plugins for one call. | None: each plugin runs with its defaults. |
These are the options of the client's methods. An endpoint's call takes a subset of them, since its definition holds the rest (see Call an endpoint).
api.request takes the same options, after the HTTP method. A GET or
HEAD request with a body makes the call die (see
When the methods aren't enough).
What's next
- Make a call: pick a method, and fill in the path and the query.
- Send a body: send JSON, a form, text or bytes.
- Read the response: decode what comes back with a schema.