Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Response
  4. Response()

Response: Response() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

Note: This feature is available inWeb Workers.

TheResponse() constructor creates a newResponse object.

Syntax

js
new Response()new Response(body)new Response(body, options)

Parameters

bodyOptional

An object defining a body for the response. This can benull (which isthe default value), or one of:

optionsOptional

An options object containing any custom settings that you want to apply to the response, or an empty object (which is the default value). The possible options are:

status

The status code for the response.The default value is200.

statusText

The status message associated with the status code, such as"OK".The default value is"".

headers

Any headers you want to add to your response, contained within aHeaders object or object literal ofString key/value pairs (seeHTTP headers for a reference).By default this is empty.

Examples

In ourFetch Response example (seeFetch Response live)we create a newResponse object using the constructor, passing it a newBlob as a body, and an init object containing a customstatus andstatusText:

js
const myBlob = new Blob();const myOptions = { status: 200, statusText: "SuperSmashingGreat!" };const myResponse = new Response(myBlob, myOptions);

Specifications

Specification
Fetch
# ref-for-dom-response①

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp