A lightweight HTTP client built on fetch with automatic retries,
configurable timeouts, and rate-limit handling via Retry-After.
An HTTP client built on fetch with automatic retries and error handling.
- config: ResolvedConfig
-
create(): WebClient
Creates a new WebClient with all defaults.
-
delete(): Task<ResponseResult, HttpError>path: string,options?: RequestOptions
Make a DELETE request.
-
get(): Task<ResponseResult, HttpError>path: string,options?: RequestOptions
Make a GET request.
-
patch(): Task<ResponseResult, HttpError>path: string,body: unknown,options?: RequestOptions
Make a PATCH request with a body.
-
post(): Task<ResponseResult, HttpError>path: string,body: unknown,options?: RequestOptions
Make a POST request with a body.
-
put(): Task<ResponseResult, HttpError>path: string,body: unknown,options?: RequestOptions
Make a PUT request with a body.
-
request(): Task<ResponseResult, HttpError>path: string,method: Method,options?: RequestOptions,body?: unknown
Make an HTTP request with the specified method.
-
withBaseUrl(url: string | URL): WebClient
Returns a new WebClient with the given base URL.
-
withFetch(fetch: globalThis.fetch): WebClient
Returns a new WebClient using the given fetch function.
-
withHeaders(headers: Record<string, string>): WebClient
Returns a new WebClient with the given headers merged into existing ones.
-
withRetry(retry: RetryOptions): WebClient
Returns a new WebClient with retry options field-merged into existing ones.
-
withTimeout(ms: number): WebClient
Returns a new WebClient with the given timeout in milliseconds.
Options for an individual request, overriding client defaults.
Successful HTTP response data.
Configuration for automatic retry behavior.
| "POST"
| "PUT"
| "PATCH"
| "DELETE"
| "HEAD"
| "OPTIONS"
HTTP request methods supported by the WebClient.