AwaitedDOM/ Response

The Response interface of the Fetch API represents the response to a request.
You can create a new Response object using the Response.Response() constructor, but you are more likely to encounter a Response object being returned as the result of another API operation—for example, a service worker Fetchevent.respondWith, or a simple GlobalFetch.fetch().

Properties

.headers
W3C

The Headers object associated with the response.

Type: Headers

.ok
W3C

A boolean indicating whether the response was successful (status in the range 200–299) or not.

Type: Promise<boolean>

.redirected
W3C

Indicates whether or not the response is the result of a redirect (that is, its URL list has more than one entry).

Type: Promise<boolean>

.status
W3C

The status code of the response. (This will be 200 for a success).

Type: Promise<number>

.statusText
W3C

The status message corresponding to the status code. (e.g., OK for 200).

Type: Promise<string>

.type
W3C

The type of the response (e.g., basic, cors).

Type: Promise<ResponseType>

.url
W3C

The URL of the response.

Type: Promise<string>

.bodyUsed
W3C

A boolean that indicates whether the body has been read.

Type: Promise<boolean>

Methods

.arrayBuffer()
W3C

Takes a Response stream and reads it to completion. It returns a promise that resolves with an ArrayBuffer.

Returns: Promise<ArrayBuffer>

.json()
W3C

Takes a Response stream and reads it to completion. It returns a promise that resolves with the result of parsing the body text as JSON.

Returns: Promise<any>

.text()
W3C

Takes a Response stream and reads it to completion. It returns a promise that resolves with a string (text). The response is always decoded using UTF-8.

Returns: Promise<string>

Unimplemented Specs

Properties

body

Methods

clone()error()
redirect()blob()
formData()

Edit this page on GitHub