TypeScript API / laikacms/json-api / JsonApiHttpTransport
Class: JsonApiHttpTransport
HTTP transport shared by the JSON:API proxy repositories: owns the base URL, auth headers, and the Effect HttpClient, and centralizes JSON:API response decoding (content-type validation, errors[] → typed LaikaError rehydration).
Constructors
Constructor
new JsonApiHttpTransport(config): JsonApiHttpTransport;Parameters
| Parameter | Type |
|---|---|
config | JsonApiHttpTransportConfig |
Returns
JsonApiHttpTransport
Methods
fetchJson()
fetchJson(
path,
init?,
opts?
): Effect<object & Record<string, unknown>, LaikaError<ErrorCode, number>>;Execute a request and decode the JSON:API document: validates the content-type, surfaces non-JSON bodies (typically upstream stack traces) in the failure message, and turns errors[] into a fatal LaikaError.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | - |
init | JsonApiRequestInit | - |
opts? | { rehydrateErrorCodes?: boolean; } | - |
opts.rehydrateErrorCodes? | boolean | Re-hydrate the upstream error's typed LaikaError subclass from its code field (falling back to InvalidData) so consumers can instanceof-check (e.g. NotFoundError). |
Returns
Effect<object & Record<string, unknown>, LaikaError<ErrorCode, number>>
request()
request(path, init?): Effect<HttpClientResponse, LaikaError<ErrorCode, number>>;Execute a request and return the raw response. Transport failures are mapped through networkError; HTTP error statuses are NOT failures here — JSON:API error documents are decoded by fetchJson.
Parameters
| Parameter | Type |
|---|---|
path | string |
init | JsonApiRequestInit |
Returns
Effect<HttpClientResponse, LaikaError<ErrorCode, number>>