1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

site

doc

blog

success stories

Response

The Response interface represents an HTTP response and integrates the Fetch API.

Constructor

let response = new Response(input [, init])

Parameters

body optional - object that defines the response body. It can be the null default value or any of the following:

init optional - options object that contains customized options for building the Response, or an empty object, which is the default value. The options are as follows:

  • status int - contains the response “status” code. For example, 200 for a success.
  • statusText - contains the “status” message corresponding to the “status” code. For example, OK for 200.
  • headers- contains the Headers object associated with the response.
  • url - contains the response URL.

Properties

headers - contains the Headers object associated with the response.

ok - contains a Boolean value indicating whether the response was successful, when the “status” is in the range 200-299, or not.

redirected - indicates whether the response is the result of a redirect or not; that is, your URL list has more than one entry.

status - contains the response “status” code. For example, 200 for a success.

statusText - contains the “status” message corresponding to the “status” code. For example, OK for 200.

type - contains the type of response. For example, basic, cors.

url - contains the response URL.

useFinalURL - contains a Boolean value indicating whether this is the final URL of the response.

Since Response implements Body, it also has the following properties available:

body - a simple “getter” to read from the body content via the ReadableStream interface. bodyUsed - stores a Boolean that indicates whether the body has already been used in a response.

Methods

clone()- creates a copy of the Response object.

redirect()- create a new response with a different URL.


Didn’t find what you were looking for? Open a support ticket.