Response
interface of the Fetch API represents the response to a request.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()
.The Headers
object associated with the response.
Headers
A boolean indicating whether the response was successful (status in the range 200
–299
) or not.
Promise<boolean>
Indicates whether or not the response is the result of a redirect (that is, its URL list has more than one entry).
Promise<boolean>
The status code of the response. (This will be 200
for a success).
Promise<number>
The status message corresponding to the status code. (e.g., OK
for 200
).
Promise<string>
The type of the response (e.g., basic
, cors
).
Promise<ResponseType>
The URL of the response.
Promise<string>
A boolean
that indicates whether the body has been read.
Promise<boolean>
Takes a Response
stream and reads it to completion. It returns a promise that resolves with an ArrayBuffer
.
Promise<ArrayBuffer>
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
.
Promise<any>
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.
Promise<string>
body |
clone() | error() |
redirect() | blob() |
formData() |