Response

This Fetch API interface represents the response to a request.

class Response implements Body {
constructor(body?: BodyInit | null, init?: ResponseInit);
readonly body: ReadableStream<Uint8Array> | null;
readonly bodyUsed: boolean;
readonly headers: Headers;
readonly ok: boolean;
readonly redirected: boolean;
readonly status: number;
readonly statusText: string;
readonly trailer: Promise<Headers>;
readonly type: ResponseType;
readonly url: string;
 
arrayBuffer(): Promise<ArrayBuffer>;
blob(): Promise<Blob>;
clone(): Response;
formData(): Promise<FormData>;
json(): Promise<any>;
text(): Promise<string>;
 
static error(): Response;
static json(data: unknown, init?: ResponseInit): Response;
static redirect(url: string | URL, status?: number): Response;
}

§Implements

§Constructors

§
new Response(body?: BodyInit | null, init?: ResponseInit)
[src]

§Properties

§
body: ReadableStream<Uint8Array> | null
[src]

A simple getter used to expose a ReadableStream of the body contents.

§
bodyUsed: boolean
[src]

Stores a Boolean that declares whether the body has been used in a response yet.

§
ok: boolean
[src]
§
redirected: boolean
[src]
§
status: number
[src]
§
statusText: string
[src]
§
trailer: Promise<Headers>
[src]
§
url: string
[src]

§Methods

§
arrayBuffer(): Promise<ArrayBuffer>
[src]

Takes a Response stream and reads it to completion. It returns a promise that resolves with an ArrayBuffer.

§
blob(): Promise<Blob>
[src]

Takes a Response stream and reads it to completion. It returns a promise that resolves with a Blob.

§
formData(): Promise<FormData>
[src]

Takes a Response stream and reads it to completion. It returns a promise that resolves with a FormData object.

§
json(): Promise<any>
[src]

Takes a Response stream and reads it to completion. It returns a promise that resolves with the result of parsing the body text as JSON.

§
text(): Promise<string>
[src]

Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text).

§Static Methods

§
json(data: unknown, init?: ResponseInit): Response
[src]
§
redirect(url: string | URL, status?: number): Response
[src]