Function: fetcher()
Effect-based HTTP client with retry, timeout, schema validation, and structured error handling. Resolves the URL by prepending the runtime-detected base URL (Vite/Next env, fallback tohttp://localhost:5173 server-side; no
prefix in the browser). Encodes params into a query string,
picks the body encoding (json / text / form) per
options.bodyType, and runs the request through HttpClient with
Schedule.exponential retry on failure.
On 4xx/5xx, timeout, transport, or body-parse failure: fails with
FetcherError. When options.schema is supplied and the
response body decodes against it: returns the typed value;
otherwise: fails with FetcherValidationError.
Prefer the verb-specific helpers (get, post,
put, patch, del, options,
head) — they have nicer overloads and avoid you specifying
the method string by hand. Reach for fetcher directly only when
the method is dynamic.
Type Param
Response shape inferred fromoptions.schema when
provided, otherwise unknown.
Param
URL or path. Absolute (http(s)://…) is used
verbatim; relative paths are joined to the resolved base URL.
Param
HTTP verb. Defaults to"GET".
Param
FetcherOptions (retries, timeout, headers, schema, abort signal, …).Param
Optional query parameters. Array values are serialised as repeated keys.Param
Optional request body for POST/PUT/PATCH. Encoded peroptions.bodyType (default "json").
Call Signature
fetcher<Defined in: packages/http/src/fetcher.ts:390T>(input,method?,options?,params?):Effect<T,FetcherValidationError|FetcherError,HttpClient>
Type Parameters
T
T = unknown
Parameters
input
string
method?
"GET"
options?
FetcherOptions<T>
params?
Returns
Effect<T, FetcherValidationError | FetcherError, HttpClient>
Call Signature
fetcher<Defined in: packages/http/src/fetcher.ts:397S>(input,method,options,params?):Effect<Type<S>,FetcherValidationError|FetcherError,HttpClient>
Type Parameters
S
S extends SyncSchema<Type<S>>
Parameters
input
string
method
"GET"
options
FetcherOptions<Type<S>> & object
params?
Returns
Effect<Type<S>, FetcherValidationError | FetcherError, HttpClient>
Call Signature
fetcher<Defined in: packages/http/src/fetcher.ts:408T>(input,method,options?,params?,body?):Effect<T,FetcherValidationError|FetcherError,HttpClient>
Type Parameters
T
T = unknown
Parameters
input
string
method
"POST" | "PUT" | "PATCH"
options?
FetcherOptions<T>
params?
body?
any
Returns
Effect<T, FetcherValidationError | FetcherError, HttpClient>
Call Signature
fetcher<Defined in: packages/http/src/fetcher.ts:416S>(input,method,options,params?,body?):Effect<Type<S>,FetcherValidationError|FetcherError,HttpClient>
Type Parameters
S
S extends SyncSchema<Type<S>>
Parameters
input
string
method
"POST" | "PUT" | "PATCH"
options
FetcherOptions<Type<S>> & object
params?
body?
any
Returns
Effect<Type<S>, FetcherValidationError | FetcherError, HttpClient>
Call Signature
fetcher<Defined in: packages/http/src/fetcher.ts:428T>(input,method,options?,params?):Effect<T,FetcherValidationError|FetcherError,HttpClient>
Type Parameters
T
T = unknown
Parameters
input
string
method
"DELETE" | "OPTIONS" | "HEAD"
options?
FetcherOptions<T>
params?
Returns
Effect<T, FetcherValidationError | FetcherError, HttpClient>