Response()
コンストラクターは、新しい Response
オブジェクトを生成します。
構文
var myResponse = new Response(body, init);
引数
- body Optional
- bodyオブジェクトには、レスポンスの本体を定義する。なお、これは
null
でも問題ない: - init Optional
- レスポンスに適用したオプションで、カスタム設定したい場合の可能なオプションは、次のとおりです。:
status
: レスポンス[応答]のステータスコードです。(例:200
)statusText
: ステータスメッセージは次のようなものです。(例:OK
など)headers
: レスポンス[応答]に追加するヘッダーは、ByteString
のキーと値のペアか、もしくはHeaders
、または文字どおりの状態で含まれます。(詳細は、HTTP headersを参照)
例
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 Response() の定義 |
現行の標準 | Initial definition |
ブラウザーの対応
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.