Signature
Parameters
The resource to fetch. Can be a URL string, URL object, or a Request object.
Optional request configuration.
RequestInit options
HTTP method:
GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS.Request headers. Can be a
Headers object, plain object, or array of key-value pairs.Request body. Supported types:
string, Buffer, URLSearchParams, ArrayBuffer, ArrayBufferView (for example Uint8Array), Blob, and FormData.Reusable transport context for this request (proxy + emulation settings, with connection behavior handled by the native layer). When provided, you must not also set
browser, os, proxy, or insecure.Browser fingerprint profile to use (e.g.,
'chrome_142', 'firefox_139').Operating system to emulate:
'windows', 'macos', 'linux', 'android', 'ios'.Proxy URL. Support depends on the native layer and proxy scheme.
Request timeout in milliseconds. Set to
0 to disable the timeout.AbortSignal for cancelling the request.
Redirect handling mode.
When
true, prevents browser emulation headers from being automatically added.When
true, accepts invalid/self-signed certificates. Use only in development.Response
Returns aResponse object with:
status: HTTP status codestatusText: HTTP status textheaders: response headersok:trueif status is 200-299url: final URL after redirectsredirected:trueif the response is the result of a redirectbody:ReadableStream<Uint8Array>ornullbodyUsed:trueif body has been consumedcontentLength: content length from headers, ornullcookies: parsed response cookies asRecord<string, string | string[]>
Response methods
json(): parse body as JSONtext(): get body as stringarrayBuffer(): get body as ArrayBufferblob(): get body as BlobformData(): parse body as FormDataclone(): clone the response
Convenience helpers
get(url, init?)callsfetch(url, { ...init, method: "GET" }).post(url, body?, init?)callsfetch(url, { ...init, method: "POST", body }).request(options)is deprecated and kept for compatibility. Preferfetch(url, init).