Response: Response() コンストラクター
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2017年3月.
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> # ref-for-dom-response①> |
ブラウザーの互換性
Loading…