Fetch

Module: whatwg.fetch Support: Experimental

Type Aliases

  • HeadersInit
  • XMLHttpRequestBodyInit
  • BodyInit
  • RequestInfo

Interface Headers

Represents HTTP headers as a case-insensitive multimap, with methods to append, retrieve, and iterate over header name-value pairs.

Since: 1.1.0 Docs: WHATWG Docs

8 members: 8 undocumented

Constructors

⚪ constructor(init)
HeadersInit

Methods

⚪ append(name, value)
string, string
⚪ delete(name)
string
⚪ get(name)
→ string?
⚪ getSetCookie()
→ sequence
⚪ has(name)
→ boolean
⚪ set(name, value)
string, string

Iterators

⚪ @@iterator
Not documented

---

Mixin Body

Mixin providing body-reading methods for Request and Response.

Since: 1.1.0 Docs: WHATWG Docs

8 members: 8 undocumented

Methods

⚪ arrayBuffer()
→ Promise
⚪ blob()
→ Promise
⚪ bytes()
→ Promise
⚪ formData()
→ Promise
⚪ json()
→ Promise
⚪ text()
→ Promise

Properties

⚪ body
Mixin providing body-reading methods for Request and Response.
⚪ bodyUsed
True if the body has already been consumed.

---

Enum RequestDestination

Indicates the type of resource being fetched, influencing content security and caching behavior.

Since: 1.1.0 Docs: WHATWG Docs
ValueDescription
``
audio
audioworklet
document
embed
font
frame
iframe
image
json
manifest
object
paintworklet
report
script
sharedworker
style
track
video
worker
xslt

Enum RequestMode

The CORS mode for a fetch request, controlling cross-origin behavior.

Since: 1.1.0 Docs: WHATWG Docs
ValueDescription
navigate
same-origin
no-cors
cors

Enum RequestCredentials

Controls whether cookies and other credentials are sent with the request.

Since: 1.1.0 Docs: WHATWG Docs
ValueDescription
omit
same-origin
include

Enum RequestCache

Determines how the request interacts with the browser's HTTP cache.

Since: 1.1.0 Docs: WHATWG Docs
ValueDescription
default
no-store
reload
no-cache
force-cache
only-if-cached

Enum RequestRedirect

Controls how HTTP redirects are handled: follow them, reject them, or expose them manually.

Since: 1.1.0 Docs: WHATWG Docs
ValueDescription
follow
error
manual

Enum RequestDuplex

Controls duplex mode for streaming request bodies; "half" means the request body can be sent before the response is received.

Since: 1.1.0 Docs: WHATWG Docs
ValueDescription
half

Enum RequestPriority

A priority hint indicating the relative importance of this fetch compared to others.

Since: 1.1.0 Docs: WHATWG Docs
ValueDescription
high
low
auto

Interface Request

Implements: Body

16 members: 16 undocumented

Constructors

⚪ constructor(input, init)
RequestInfo, RequestInit

Methods

⚪ clone()
→ Request

Properties

⚪ method
→ string
⚪ url
The request URL.
⚪ headers
The request URL.
⚪ destination
The intended use context for the requested resource.
⚪ referrer
The intended use context for the requested resource.
⚪ referrerPolicy
The referrer policy governing how `referrer` is sent.
⚪ mode
The referrer policy governing how `referrer` is sent.
⚪ credentials
The CORS mode for the request.
⚪ cache
Determines how the request interacts with the browser's HTTP cache.
⚪ redirect
How redirects are handled.
⚪ integrity
How redirects are handled.
⚪ keepalive
Whether the connection should be kept alive after the response.
⚪ signal
The AbortSignal associated with this request.
⚪ duplex
The AbortSignal associated with this request.

---

Dictionary RequestInit

14 members: 14 undocumented

Properties

⚪ method
→ string
⚪ headers
The request URL.
⚪ body
Mixin providing body-reading methods for Request and Response.
⚪ referrer
The intended use context for the requested resource.
⚪ referrerPolicy
The referrer policy governing how `referrer` is sent.
⚪ mode
The referrer policy governing how `referrer` is sent.
⚪ credentials
The CORS mode for the request.
⚪ cache
Determines how the request interacts with the browser's HTTP cache.
⚪ redirect
How redirects are handled.
⚪ integrity
How redirects are handled.
⚪ keepalive
Whether the connection should be kept alive after the response.
⚪ signal
The AbortSignal associated with this request.
⚪ duplex
The AbortSignal associated with this request.
⚪ priority
→ RequestPriority

---

Enum ResponseType

Classifies the response origin and filtering applied by the Fetch algorithm.

Since: 1.1.0 Docs: WHATWG Docs
ValueDescription
basic
cors
default
error
opaque
opaqueredirect

Interface Response

Represents an HTTP response with status, headers, and body, including static factory methods for common patterns like redirects, JSON responses, and errors.

Implements: Body Since: 1.1.0 Docs: WHATWG Docs

12 members: 12 undocumented

Constructors

⚪ constructor(body, init)
BodyInit?, ResponseInit

Static Methods

⚪ error()
Controls how HTTP redirects are handled: follow them, reject them, or expose them manually.
⚪ redirect(url, status)
How redirects are handled.
⚪ json(data, init)
→ Response

Methods

⚪ clone()
→ Response

Properties

⚪ type
→ ResponseType
⚪ url
The request URL.
⚪ redirected
True if the response was the result of a redirect.
⚪ status
→ u16
⚪ ok
True if `status` is in the range 200–299.
⚪ statusText
The HTTP status reason phrase (e.g. `"OK"`).
⚪ headers
The request URL.

---

Dictionary ResponseInit

3 members: 3 undocumented

Properties

⚪ status
→ u16
⚪ statusText
The HTTP status reason phrase (e.g. `"OK"`).
⚪ headers
The request URL.

---