The Response()
constructor creates a new Response
object.
var myResponse = new Response(body, init);
null
, or one of: status
: The status code for the reponse, e.g., 200
.statusText
: The status message associated with the status 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 |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 42
|
15 | 39
|
No | 29
|
10.1 |
body parameter accepts ReadableByteStream | 52 | ? | No | No | 39 | No |
body parameter can be null
|
Yes | ? | 59 | No | Yes | No |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 42
|
42
|
Yes | Yes | 29
|
10.3 | 4.0 |
body parameter accepts ReadableByteStream | 52 | 52 | ? | No | 29 | 10.3 | 6.0 |
body parameter can be null
|
Yes | Yes | ? | Yes | Yes | No | Yes |
© 2005–2018 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