Response()
Response()
コンストラクターは、新しい Response
オブジェクトを生成します。
構文
var myResponse = new Response(body, init);
引数
- body 省略可
- bodyオブジェクトには、レスポンスの本体を定義する。なお、これは
null
でも問題ない: - init 省略可
- レスポンスに適用したオプションで、カスタム設定したい場合の可能なオプションは、次のとおりです。:
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