Response()
Response()
コンストラクターは、新しい Response
オブジェクトを生成します。
構文
js
new Response()
new Response(body)
new Response(body, options)
引数
body
省略可-
レスポンスの本体を定義するオブジェクトです。これは
null
(既定値)か、以下のうちのいずれかです。 options
省略可-
レスポンスに適用したオプションで、カスタム設定したい場合の可能なオプションは、次のとおりです。:
例
Fetch Response の例 (Fetch Response のライブ版を参照)では、コンストラクターを使用して新しい Response
オブジェクトを作成します。その際、新しい Blob
を本体として、またカスタム status
と statusText
を含む init オブジェクトを渡します。
js
const myBlob = new Blob();
const myOptions = { status: 200, statusText: "SuperSmashingGreat!" };
const myResponse = new Response(myBlob, myOptions);
仕様書
Specification |
---|
Fetch Standard # ref-for-dom-response① |
ブラウザーの互換性
BCD tables only load in the browser