This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
The Response()
constructor creates a new Response
object.
var myResponse = new Response(body, init);
status
: The status code for the reponse, e.g., 200
.statusText
: The status message associated with the staus code, e.g., OK
.headers
: Any headers you want to add to your response, contained within a Headers
object or object literal of ByteString
key/value pairs (see HTTP headers for a reference).In our Fetch Response example (see Fetch Response live) we create a new Response
object using the constructor, passing it a new Blob
as a body, and an init object containing a custom status
and statusText
:
var myBlob = new Blob(); var init = { "status" : 200 , "statusText" : "SuperSmashingGreat!" }; var myResponse = new Response(myBlob,init);
Specification | Status | Comment |
---|---|---|
Fetch The definition of 'Response()' in that specification. | Living Standard | Initial definition |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 42.0 41.0[1] |
39 (39) 34[1] | No support | 29 | No support |
body parameter accepts ReadableByteStream | 52.0 | 39 |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | No support | 42.0 41.0[1] | No support | No support | No support | 29 | No support | 42.0 41.0[1] |
body parameter accepts ReadableByteStream | No support | 52.0 | 29 | 52.0 |
[1] This feature is implemented behind a preference.
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Response/Response