class Response
Supported only in the v8 engine. Introduced in Max v9.2.0.
A response returned by fetch().
Index
Constructors
Properties
Methods
new Response(body, init)
new Response(
body?: BodyInit | null,
init?: { status?: number; statusText?: string; headers?: HeadersInit },
);
Constructs a new instance of the Response class
| Parameter | Type | Description |
|---|---|---|
| optional body | BodyInit | null | the response body. |
| optional init | object | response status and headers. optional init.status number optional init.statusText string optional init.headers HeadersInit |
arrayBuffer()
Reads the body as an ArrayBuffer.
arrayBuffer(): Promise<ArrayBuffer>;
| Name | Type | Description |
|---|---|---|
| Return Value | Promise<ArrayBuffer> |
blob()
Reads the body as a Blob using the current content-type.
blob(): Promise<Blob>;
| Name | Type | Description |
|---|---|---|
| Return Value | Promise<Blob> |
body ReadableStream | null read-only
A byte-oriented ReadableStream for incremental body consumption, or null. Canceling it aborts the underlying native transport.
bodyUsed boolean read-only
Whether the body has already been consumed.
bytes()
Reads the body as bytes.
bytes(): Promise<buffer.IOBuffer>;
| Name | Type | Description |
|---|---|---|
| Return Value | Promise<buffer.IOBuffer> |
clone()
Clones the response (tee-based; throws once the body is consumed).
clone(): Response;
| Name | Type | Description |
|---|---|---|
| Return Value | Response |
headers Headers read-only
The response headers.
json()
Reads and parses the body as JSON.
json(): Promise<any>;
| Name | Type | Description |
|---|---|---|
| Return Value | Promise<any> |
ok boolean read-only
Whether Response.status is in the range 200–299.
status number read-only
The HTTP status code.
statusText string read-only
The HTTP status text.
text()
Reads the body as a UTF-8 string.
text(): Promise<string>;
| Name | Type | Description |
|---|---|---|
| Return Value | Promise<string> |
url string read-only
The final response URL after any redirects.