Skip to content

Interface: FetchInit ​

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

fetch() options for browsers, Web Workers and other fetch() runtimes (Deno, Bun). Node.js requests don't use them; they're still validated there.

Extends ​

Properties ​

allowAbsoluteUrls? ​

optional allowAbsoluteUrls?: boolean

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

Overrides the client's allowAbsoluteUrls

Inherited from ​

RequestOptions.allowAbsoluteUrls


allowInsecureRedirects? ​

optional allowInsecureRedirects?: boolean

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

Overrides the client's allowInsecureRedirects

Inherited from ​

RequestOptions.allowInsecureRedirects


allowPrivateNetwork? ​

optional allowPrivateNetwork?: boolean

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

Overrides the client's allowPrivateNetwork

Inherited from ​

RequestOptions.allowPrivateNetwork


body? ​

optional body?: RequestBody

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


cache? ​

optional cache?: "default" | "no-store" | "reload" | "no-cache" | "force-cache" | "only-if-cached"

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

How the browser's HTTP cache is used

Inherited from ​

RequestOptions.cache


connectTimeoutMs? ​

optional connectTimeoutMs?: number

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

Time until a connection is established, including TLS (Node.js); browsers cannot observe it. 0 disables.

Inherited from ​

RequestOptions.connectTimeoutMs


credentials? ​

optional credentials?: "omit" | "same-origin" | "include"

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

Send cookies and HTTP authentication: same-origin (default), include (also cross-origin) or omit

Inherited from ​

RequestOptions.credentials


deadlineMs? ​

optional deadlineMs?: number

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

Total logical-request deadline, including queueing, retries and reading the body. 0 disables.

Inherited from ​

RequestOptions.deadlineMs


dedupe? ​

optional dedupe?: boolean

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

get and head only: share one request and response with identical requests in flight at once (same URL, headers and options), or false to opt out when the client's dedupe is on. Each caller gets its own response object. Not with streamed responseTypes.

Inherited from ​

RequestOptions.dedupe


headers? ​

optional headers?: HeadersLike

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

Inherited from ​

RequestOptions.headers


httpCache? ​

optional httpCache?: boolean

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

false skips the client's httpCache for this request: nothing is served from it or stored in it.

Inherited from ​

RequestOptions.httpCache


idempotencyHeader? ​

optional idempotencyHeader?: string

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

Overrides the client's idempotency header name

Inherited from ​

RequestOptions.idempotencyHeader


idempotencyKey? ​

optional idempotencyKey?: string | boolean

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

Overrides the client's key policy. true generates a key for this call; false disables it. Requires server deduplication.

Inherited from ​

RequestOptions.idempotencyKey


idleTimeoutMs? ​

optional idleTimeoutMs?: number

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

Maximum wait for the next body chunk, including streams and SSE. 0 disables.

Inherited from ​

RequestOptions.idleTimeoutMs


integrity? ​

optional integrity?: string

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

Subresource integrity metadata, e.g. sha384-…

Inherited from ​

RequestOptions.integrity


keepalive? ​

optional keepalive?: boolean

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

Let the request outlive the page, e.g. for analytics on unload (bodies up to 64 KB)

Inherited from ​

RequestOptions.keepalive


maxLineBytes? ​

optional maxLineBytes?: number | null

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

responseType: 'ndjson': overrides the client's maxLineBytes; null removes the limit for this request

Inherited from ​

RequestOptions.maxLineBytes


maxRedirects? ​

optional maxRedirects?: number

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

Overrides the client's maxRedirects

Inherited from ​

RequestOptions.maxRedirects


maxResponseBytes? ​

optional maxResponseBytes?: number | null

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

Overrides the client's maxResponseBytes; null removes the limit for this request

Inherited from ​

RequestOptions.maxResponseBytes


method? ​

optional method?: string

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

HTTP method. Default: GET


mode? ​

optional mode?: "same-origin" | "cors" | "no-cors"

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

cors (default), same-origin, or no-cors, which resolves with an opaque response (status: 0, no headers, no body)

Inherited from ​

RequestOptions.mode


onDownloadProgress? ​

optional onDownloadProgress?: (progress) => void

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

Called after each received chunk of a successful response

Parameters ​

progress ​

DownloadProgress

Returns ​

void

Inherited from ​

RequestOptions.onDownloadProgress


onUploadProgress? ​

optional onUploadProgress?: (progress) => void

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

Called as the request body is sent; starts again from 0 if the request is retried. Browsers send these requests with XMLHttpRequest (cross-origin ones are preflighted). Can't be combined with responseType: 'stream'.

Parameters ​

progress ​

UploadProgress

Returns ​

void

Inherited from ​

RequestOptions.onUploadProgress


params? ​

optional params?: QueryParams

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

Inherited from ​

RequestOptions.params


priority? ​

optional priority?: "high" | "low" | "auto"

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

Fetch priority, where the browser supports it

Inherited from ​

RequestOptions.priority


redirect? ​

optional redirect?: RedirectMode

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

Overrides the client's redirect

Inherited from ​

RequestOptions.redirect


referrer? ​

optional referrer?: string

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

A same-origin URL, '' for none, or about:client (default)

Inherited from ​

RequestOptions.referrer


referrerPolicy? ​

optional referrerPolicy?: "" | "origin" | "same-origin" | "no-referrer" | "no-referrer-when-downgrade" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url"

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

Inherited from ​

RequestOptions.referrerPolicy


responseTimeoutMs? ​

optional responseTimeoutMs?: number

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

Time until final response headers arrive. 0 disables.

Inherited from ​

RequestOptions.responseTimeoutMs


responseType? ​

optional responseType?: ResponseBodyType

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

Inherited from ​

RequestOptions.responseType


resume? ​

optional resume?: boolean | { maxResumes?: number; }

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

get with responseType: 'stream' only: when the connection breaks mid-body, continue with a Range request (checked with If-Range) instead of failing, up to maxResumes times (default 3). Needs a server that sends Accept-Ranges: bytes, an ETag or Last-Modified, and no Content-Encoding; otherwise the stream fails as usual. response.resumes counts the continuations.

Inherited from ​

RequestOptions.resume


retries? ​

optional retries?: number | RetryOptions

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

Replaces the client's retry policy for this request (also for events() connection attempts). 0 disables retries. Omitted object fields use the standard defaults, not the client's values. The client's shared retryBudget still applies. Separate from events()'s reconnect.

Inherited from ​

RequestOptions.retries


schema? ​

optional schema?: StandardSchema<unknown>

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

Validate the response body with a Standard Schema (Zod, Valibot, ArkType…). The body of the response becomes the schema's output; a body that fails rejects with a ValidationError (not retried). Not with responseType: 'stream' or 'ndjson'.

Inherited from ​

RequestOptions.schema


sensitiveHeaders? ​

optional sensitiveHeaders?: string[]

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

Overrides the client's sensitiveHeaders

Inherited from ​

RequestOptions.sensitiveHeaders


signal? ​

optional signal?: AbortSignal

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

Cancels the request (including pending retries) when aborted; rejects with a CancelledError. For responseType: 'stream' it also errors the body stream.

Inherited from ​

RequestOptions.signal


timeoutMs? ​

optional timeoutMs?: number

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

Overrides the client timeout for this request, in ms. 0 disables it.

Inherited from ​

RequestOptions.timeoutMs

Released under the MIT or Apache-2.0 license.