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().
Constructor
Response()- Creates a new
Responseobject.
Properties
Response.headersRead only- Contains the
Headersobject associated with the response. Response.okRead only- Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
Response.redirectedRead only- Indicates whether or not the response is the result of a redirect; that is, its URL list has more than one entry.
Response.statusRead only- Contains the status code of the response (e.g.,
200for a success). Response.statusTextRead only- Contains the status message corresponding to the status code (e.g.,
OKfor200). Response.typeRead only- Contains the type of the response (e.g.,
basic,cors). Response.urlRead only- Contains the URL of the response.
Response.useFinalURL- Contains a boolean stating whether this is the final URL of the response.
Response implements Body, so it also has the following properties available to it:
Body.bodyRead only- A simple getter used to expose a
ReadableStreamof the body contents. Body.bodyUsedRead only- Stores a
Booleanthat declares whether the body has been used in a response yet.
Methods
Response.clone()- Creates a clone of a
Responseobject. Response.error()- Returns a new
Responseobject associated with a network error. Response.redirect()- Creates a new response with a different URL.
Response implements Body, so it also has the following methods available to it:
Body.arrayBuffer()- Takes a
Responsestream and reads it to completion. It returns a promise that resolves with anArrayBuffer. Body.blob()- Takes a
Responsestream and reads it to completion. It returns a promise that resolves with aBlob. Body.formData()- Takes a
Responsestream and reads it to completion. It returns a promise that resolves with aFormDataobject. Body.json()- Takes a
Responsestream and reads it to completion. It returns a promise that resolves with the result of parsing the body text asJSON. Body.text()- Takes a
Responsestream and reads it to completion. It returns a promise that resolves with aUSVString(text).
Examples
In our basic fetch example (run example live) we use a simple fetch() call to grab an image and display it in an <img> tag. The fetch() call returns a promise, which resolves with the Response object associated with the resource fetch operation. You'll notice that since we are requesting an image, we need to run Body.blob (Response implements body) to give the response its correct MIME type.
const image = document.querySelector('.my-image');
fetch('flowers.jpg').then(function(response) {
return response.blob();
}).then(function(blob) {
const objectURL = URL.createObjectURL(blob);
image.src = objectURL;
});
You can also use the Response.Response() constructor to create your own custom Response object:
const response = new Response();
Specifications
| Specification | Status | Comment |
|---|---|---|
| Fetch The definition of 'Response' in that specification. |
Living Standard | Initial definition |
Browser compatibility
| Desktop | Mobile | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Response | Chrome
Full support
42
| Edge Full support Yes | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari Full support 10.1 | WebView Android
Full support
42
| Chrome Android
Full support
42
| Edge Mobile Full support Yes | Firefox Android Full support Yes | Opera Android
Full support
29
| Safari iOS Full support 10.1 | Samsung Internet Android Full support 4.0 |
Response() constructor | Chrome
Full support
42
| Edge Full support 15 | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari Full support 10.1 | WebView Android
Full support
42
| Chrome Android
Full support
42
| Edge Mobile Full support Yes | Firefox Android Full support Yes | Opera Android
Full support
29
| Safari iOS Full support 10.3 | Samsung Internet Android Full support 4.0 |
headers | Chrome
Full support
42
| Edge Full support 14 | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile Full support Yes | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
ok | Chrome
Full support
42
| Edge Full support 14 | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile Full support Yes | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
redirected | Chrome Full support 60 | Edge Full support 16 | Firefox Full support 49 | IE No support No | Opera Full support 47 | Safari No support No | WebView Android Full support 60 | Chrome Android Full support 60 | Edge Mobile Full support Yes | Firefox Android Full support 49 | Opera Android Full support 47 | Safari iOS No support No | Samsung Internet Android No support No |
status | Chrome
Full support
42
| Edge Full support 14 | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile Full support Yes | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
statusText | Chrome
Full support
42
| Edge Full support 14 | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile Full support Yes | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
type | Chrome
Full support
42
| Edge Full support 14 | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile Full support Yes | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
url | Chrome
Full support
42
| Edge Full support 14 | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile Full support Yes | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
useFinalURL | Chrome
Full support
42
| Edge Full support Yes | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile Full support Yes | Firefox Android
Full support
39
| Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
clone | Chrome
Full support
42
| Edge Full support 14 | Firefox
Full support
39
| IE No support No | Opera
Full support
29
| Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile Full support Yes | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
error | Chrome Full support Yes | Edge Full support 16 | Firefox Full support Yes | IE No support No | Opera Full support Yes | Safari Full support Yes | WebView Android No support No | Chrome Android No support No | Edge Mobile ? | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
redirect | Chrome Full support Yes | Edge Full support 16 | Firefox Full support Yes | IE No support No | Opera Full support Yes | Safari Full support Yes | WebView Android No support No | Chrome Android No support No | Edge Mobile ? | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
trailer | Chrome No support No | Edge ? | Firefox ? | IE No support No | Opera ? | Safari ? | WebView Android ? | Chrome Android ? | Edge Mobile ? | Firefox Android ? | Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
- User must explicitly enable this feature.
- User must explicitly enable this feature.

