nx.js
Classes

Response

Class representing a HTTP response.

Extends

  • Body

Implements

Constructors

new Response()

new Response(body?, init?): Response

Create a new Response.

Parameters

ParameterTypeDescription
body?null | BodyInitThe body of the response.
init?ResponseInitInitialization options for the response.

Returns

Response

Overrides

Body.constructor

Properties

PropertyTypeDescriptionInherited from
bodynull | ReadableStream<Uint8Array>MDN ReferenceglobalThis.Response.body Body.body
bodyUsedbooleanMDN ReferenceglobalThis.Response.bodyUsed Body.bodyUsed
headersHeaders-globalThis.Response.headers Body.headers
redirectedbooleanWhether the response was redirected.-
statusnumberHTTP status code of the response.-
statusTextstringStatus text of the response.-
typeResponseTypeType of the response.-
urlstringURL of the response.-

Accessors

ok

get ok(): boolean

Check if the response was successful.

Returns

boolean

  • True if the status is between 200 and 299, inclusive.

Implementation of

globalThis.Response.ok

Methods

arrayBuffer()

arrayBuffer(): Promise<ArrayBuffer>

Returns a promise that resolves with an ArrayBuffer representation of the body. If the body is null, it returns an empty ArrayBuffer.

Returns

Promise<ArrayBuffer>

Implementation of

globalThis.Response.arrayBuffer

Inherited from

Body.arrayBuffer


blob()

blob(): Promise<Blob>

Returns a promise that resolves with a Blob representation of the body. The Blob's type will be the value of the 'content-type' header.

Returns

Promise<Blob>

Implementation of

globalThis.Response.blob

Inherited from

Body.blob


clone()

clone(): Response

Clone the response.

Returns

Response

Implementation of

globalThis.Response.clone

Throws

  • This method is not implemented.

formData()

formData(): Promise<FormData>

Returns a promise that resolves with a FormData representation of the body. If the body cannot be decoded as form data, it throws a TypeError.

Returns

Promise<FormData>

Implementation of

globalThis.Response.formData

Inherited from

Body.formData


json()

json(): Promise<any>

Returns a promise that resolves with a JSON representation of the body. If the body cannot be parsed as JSON, it throws a SyntaxError.

Returns

Promise<any>

Implementation of

globalThis.Response.json

Inherited from

Body.json


text()

text(): Promise<string>

Returns a promise that resolves with a text representation of the body.

Returns

Promise<string>

Implementation of

globalThis.Response.text

Inherited from

Body.text


error()

static error(): Response

Create a new error response.

Returns

Response

  • The new error response.

json()

static json(data, init): Response

Create a new JSON response.

Parameters

ParameterTypeDescription
dataanyThe data to include in the response body.
initResponseInitInitialization options for the response.

Returns

Response

  • The new JSON response.

redirect()

static redirect(url, status): Response

Create a new redirect response.

Parameters

ParameterTypeDefault valueDescription
urlstring | URLundefinedThe URL to redirect to.
statusnumber302The status code for the redirect, defaults to 302.

Returns

Response

  • The new redirect response.

On this page