Skip to content

Class: WasmClient ​

Defined in: api/rust-fetch.d.ts:203

HTTP client for JavaScript

Constructors ​

Constructor ​

new WasmClient(options?): WasmClient

Defined in: api/rust-fetch.d.ts:870

Create a new client

Parameters ​

options? ​

ClientOptions | null

Returns ​

WasmClient

Properties ​

retriesRefused ​

readonly retriesRefused: number

Defined in: api/rust-fetch.d.ts:913

Retries the client's retryBudget has refused so far (0 without a budget)

Methods ​

[dispose]() ​

[dispose](): void

Defined in: api/rust-fetch.d.ts:825

Returns ​

void


addRequestInterceptor() ​

addRequestInterceptor(interceptor): number

Defined in: api/rust-fetch.d.ts:829

Run interceptor on every request before it is sent; returns an id for ejectInterceptor

Parameters ​

interceptor ​

RequestInterceptor

Returns ​

number


addResponseInterceptor() ​

addResponseInterceptor(on_fulfilled?, on_rejected?): number

Defined in: api/rust-fetch.d.ts:834

Run handlers on every settled request, like promise.then(onFulfilled, onRejected); returns an id for ejectInterceptor

Parameters ​

on_fulfilled? ​

ResponseFulfilledInterceptor | null

on_rejected? ​

ResponseRejectedInterceptor | null

Returns ​

number


clearInterceptors() ​

clearInterceptors(): void

Defined in: api/rust-fetch.d.ts:838

Remove all interceptors

Returns ​

void


delete() ​

Call Signature ​

delete<S>(url, options): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:842

Make a DELETE request

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

options ​

RequestOptions & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

delete<T>(url, options?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:843

Make a DELETE request

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

options? ​

RequestOptions | null

Returns ​

Promise<HttpResponse<T>>


ejectInterceptor() ​

ejectInterceptor(id): boolean

Defined in: api/rust-fetch.d.ts:847

Remove an interceptor; returns whether it was registered

Parameters ​

id ​

number

Returns ​

boolean


events() ​

events(url, options?): EventStream

Defined in: api/rust-fetch.d.ts:851

Open a Server-Sent Events stream. Relative URLs are resolved against the base URL.

Parameters ​

url ​

string

options? ​

EventStreamOptions | null

Returns ​

EventStream


extend() ​

extend(overrides?): WasmClient

Defined in: api/rust-fetch.d.ts:820

A new client with this client's options and interceptors, and overrides on top: headers are merged by name, every other option is replaced. Circuit breakers, rate limits, concurrency limits and retry budgets are not shared: the new client has its own.

Parameters ​

overrides? ​

ClientOptions | null

Returns ​

WasmClient


fetch() ​

Call Signature ​

fetch<S>(url, init): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:855

Make a request described by a fetch-style init object

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

init ​

FetchInit & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

fetch<T>(url, init?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:856

Make a request described by a fetch-style init object

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

init? ​

FetchInit | null

Returns ​

Promise<HttpResponse<T>>


free() ​

free(): void

Defined in: api/rust-fetch.d.ts:824

Returns ​

void


get() ​

Call Signature ​

get<S>(url, options): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:860

Make a GET request

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

options ​

RequestOptions & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

get<T>(url, options?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:861

Make a GET request

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

options? ​

RequestOptions | null

Returns ​

Promise<HttpResponse<T>>


Call Signature ​

head<S>(url, options): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:865

Make a HEAD request

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

options ​

RequestOptions & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

head<T>(url, options?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:866

Make a HEAD request

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

options? ​

RequestOptions | null

Returns ​

Promise<HttpResponse<T>>


paginate() ​

Call Signature ​

paginate<T>(url, options): AsyncGenerator<T, void, undefined>

Defined in: api/rust-fetch.d.ts:822

Pages of a paginated API, or its items with items. Follows the Link: rel="next" header unless next says otherwise; each page is a normal GET.

Type Parameters ​
T ​

T

Parameters ​
url ​

string

options ​

PaginateOptions & object

Returns ​

AsyncGenerator<T, void, undefined>

Call Signature ​

paginate(url, options?): AsyncGenerator<HttpResponse<any>, void, undefined>

Defined in: api/rust-fetch.d.ts:823

Pages of a paginated API, or its items with items. Follows the Link: rel="next" header unless next says otherwise; each page is a normal GET.

Parameters ​
url ​

string

options? ​

PaginateOptions

Returns ​

AsyncGenerator<HttpResponse<any>, void, undefined>


patch() ​

Call Signature ​

patch<S>(url, init): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:874

Make a PATCH request; the body is taken from init.body

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

init ​

FetchInit & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

patch<T>(url, init?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:875

Make a PATCH request; the body is taken from init.body

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

init? ​

FetchInit | null

Returns ​

Promise<HttpResponse<T>>


patch_json() ​

Call Signature ​

patch_json<S>(url, body, options): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:879

Make a PATCH request with a JSON body

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

body ​

any

options ​

RequestOptions & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

patch_json<T>(url, body, options?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:880

Make a PATCH request with a JSON body

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

body ​

any

options? ​

RequestOptions | null

Returns ​

Promise<HttpResponse<T>>


post() ​

Call Signature ​

post<S>(url, init): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:884

Make a POST request; the body is taken from init.body

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

init ​

FetchInit & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

post<T>(url, init?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:885

Make a POST request; the body is taken from init.body

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

init? ​

FetchInit | null

Returns ​

Promise<HttpResponse<T>>


post_json() ​

Call Signature ​

post_json<S>(url, body, options): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:889

Make a POST request with a JSON body

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

body ​

any

options ​

RequestOptions & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

post_json<T>(url, body, options?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:890

Make a POST request with a JSON body

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

body ​

any

options? ​

RequestOptions | null

Returns ​

Promise<HttpResponse<T>>


put() ​

Call Signature ​

put<S>(url, init): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:894

Make a PUT request; the body is taken from init.body

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

init ​

FetchInit & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

put<T>(url, init?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:895

Make a PUT request; the body is taken from init.body

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

init? ​

FetchInit | null

Returns ​

Promise<HttpResponse<T>>


put_json() ​

Call Signature ​

put_json<S>(url, body, options): Promise<HttpResponse<InferSchemaOutput<S>>>

Defined in: api/rust-fetch.d.ts:899

Make a PUT request with a JSON body

Type Parameters ​
S ​

S extends StandardSchema<unknown>

Parameters ​
url ​

string

body ​

any

options ​

RequestOptions & object

Returns ​

Promise<HttpResponse<InferSchemaOutput<S>>>

Call Signature ​

put_json<T>(url, body, options?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:900

Make a PUT request with a JSON body

Type Parameters ​
T ​

T = any

Parameters ​
url ​

string

body ​

any

options? ​

RequestOptions | null

Returns ​

Promise<HttpResponse<T>>


request() ​

request<T>(method, url, headers?, body?, options?): Promise<HttpResponse<T>>

Defined in: api/rust-fetch.d.ts:904

Make a request with any method, headers and body

Type Parameters ​

T ​

T = any

Parameters ​

method ​

string

url ​

string

headers? ​

HeadersLike | null

body? ​

RequestBody

options? ​

RequestOptions | null

Returns ​

Promise<HttpResponse<T>>


stats() ​

stats(): ClientStats

Defined in: api/rust-fetch.d.ts:205

Enable collection from this call onward (or configure metrics: true); returns a detached snapshot.

Returns ​

ClientStats


websocket() ​

websocket(url, options?): WebSocketConnection

Defined in: api/rust-fetch.d.ts:909

Open a WebSocket connection. Relative URLs are resolved against the base URL, with http: and https: becoming ws: and wss:.

Parameters ​

url ​

string

options? ​

WebSocketOptions | null

Returns ​

WebSocketConnection

Released under the MIT or Apache-2.0 license.