API Reference
Methods and options for Plasma HTTP client
createHttpClient(config)
Creates a typed HTTP client.
| Option | Type | Description |
|---|---|---|
serverUrl | string | undefined | Base URL for your API |
routes | ServerRoutes | Route definitions object |
adapter | (data: any) => any | (Optional) Transform the response body |
interceptors | Interceptors | (Optional) Request/response interceptors |
client.GET(alias[, options])
optionsis omittable when the route has noparamsschemaoptionsis required (and must includeparams) when the route defines aparams: z.object(...)schema
// Route defines `params: z.object(...)` — options is required
const [, ] = await .('get-users', {
: { : 1, : 'admin' }, // required
: true, // optional, default: true
})
// Route has no `params` schema — second argument can be omitted entirely
const [, ] = await .('get-profile')
// Or pass options to override auth when no params are needed
const [, ] = await .('get-profile', { : false })| Property | Required | Type | Default | Description |
|---|---|---|---|---|
params | When route defines a params schema | z.infer<Route["params"]> | — | Query parameters, validated and coerced by the route's Zod schema |
auth | No | boolean | true | Whether to enforce the Authorization header |
client.POST(alias, body[, options])
If the route defines an apiPayload schema, the body is validated and coerced before being sent. Invalid data returns [ZodError, null] without making a network request.
Options (all optional):
| Property | Required | Type | Default | Description |
|---|---|---|---|---|
params | No | object | — | Query parameters appended to the URL |
bodyType | No | 'json' | 'form-data' | 'json' | Serialization format |
auth | No | boolean | true | Whether to enforce the Authorization header |
client.PATCH(alias, body[, options])
Identical signature to client.POST. Use for partial update requests.