Response interface represents an HTTP response and integrates the Fetch API.
ConstructorSection titled Constructor
ParametersSection titled 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:
statusint - contains the response “status” code. For example, 200 for success.
statusText- contains the “status” message corresponding to the “status” code. For example, OK for 200.
headers- contains the
Headersobject associated with the response.
url- contains the response URL.
PropertiesSection titled 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 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.
MethodsSection titled Methods
clone()- creates a copy of the
redirect()- creates a new response with a different URL.
For more information on Response visit MDN Web Docs.