fetch()
Make an HTTP request.The resource to fetch. Can be a Request object or a URL string.
Optional configuration object:
method: HTTP method (GET,POST,PUT,DELETE, etc.)headers: Headers object or recordbody: Request body (string, ArrayBuffer, FormData, ReadableStream, etc.)redirect: Redirect handling (follow,error,manual)cf: Cloudflare-specific optionssignal: AbortSignal for cancellation
Promise<Response>
Resolves to a Response object representing the HTTP response.
Request
Represents an HTTP request.Constructor
Properties
HTTP method (e.g.,
GET, POST).Full URL of the request.
Headers object containing request headers.
Request body as a stream, or null if no body.
True if the body has been read.
Redirect mode:
follow, error, or manual.AbortSignal for cancelling the request.
Cloudflare-specific request properties (available on incoming requests).
Methods
Create a copy of the request.
Read the request body as an ArrayBuffer.
Read the request body as a Uint8Array.
Read the request body as a string.
Parse the request body as JSON.
Parse the request body as form data.
Read the request body as a Blob.
Response
Represents an HTTP response.Constructor
Response body: string, ArrayBuffer, Blob, FormData, URLSearchParams, or ReadableStream.
Optional configuration:
status: HTTP status code (default: 200)statusText: Status messageheaders: Headers object or recordcf: Cloudflare-specific optionswebSocket: WebSocket to acceptencodeBody: Encoding type (auto,manual)
Properties
HTTP status code.
HTTP status message.
True if status is in the range 200-299.
Headers object containing response headers.
Response body as a stream, or null if no body.
True if the body has been read.
True if the response is the result of a redirect.
Final URL after redirects.
WebSocket if this response accepted a WebSocket upgrade.
Methods
Create a copy of the response.
Read the response body as an ArrayBuffer.
Read the response body as a Uint8Array.
Read the response body as a string.
Parse the response body as JSON.
Parse the response body as form data.
Read the response body as a Blob.
Static methods
Create a Response with JSON body.
Create a redirect response.
Headers
Represents HTTP headers.Constructor
Methods
Get a header value.
Check if a header exists.
Set a header value, replacing any existing value.
Append a value to a header.
Delete a header.
Iterate over headers.
Get an iterator of [name, value] pairs.
Get an iterator of header names.
Get an iterator of header values.