global.Response
A fetch response, for checking its status and reading its body whole or as it streams in.
Usage
Measure an operation without relying on wall-clock changes.
This type is used by global.fetch
// Measure an operation without relying on wall-clock changes.
const start = performance.now();
const response = await fetch('https://example.com/api/health');
console.log(response.status, performance.now() - start);Type declaration
interface Response {
readonly ok: boolean;
readonly status: number;
readonly statusText: string;
/** The URL that answered, after redirects. */
readonly url: string;
readonly headers: Headers;
readonly bodyUsed: boolean;
arrayBuffer(): Promise<ArrayBuffer>;
bytes(): Promise<Uint8Array>;
text(): Promise<string>;
json(): Promise<unknown>;
/**
* Kuito's streaming read, in place of the Streams API: `onChunk` gets
* the body piece by piece as it arrives; resolves when it ends.
*/
chunks(onChunk: (chunk: Uint8Array) => void): Promise<void>;
}Members 11
| Name | Type | Required | Description |
|---|---|---|---|
okreadonly | boolean | Yes | — |
statusreadonly | number | Yes | — |
statusTextreadonly | string | Yes | — |
urlreadonly | string | Yes | The URL that answered, after redirects. |
headersreadonly | Headers | Yes | — |
bodyUsedreadonly | boolean | Yes | — |
arrayBuffer | () => Promise<ArrayBuffer> | Yes | — |
bytes | () => Promise<Uint8Array> | Yes | — |
text | () => Promise<string> | Yes | — |
json | () => Promise<unknown> | Yes | — |
chunks | (onChunk: (chunk: Uint8Array) => void) => Promise<void> | Yes | Kuito's streaming read, in place of the Streams API: onChunk gets
the body piece by piece as it arrives; resolves when it ends. |
arrayBuffer — method signatures
Signatures
(): Promise<ArrayBuffer>Parameters
No parameters.
Returns
Promise<ArrayBuffer>
bytes — method signatures
Signatures
(): Promise<Uint8Array>Parameters
No parameters.
Returns
Promise<Uint8Array<ArrayBufferLike>>
text — method signatures
Signatures
(): Promise<string>Parameters
No parameters.
Returns
Promise<string>
json — method signatures
Signatures
(): Promise<unknown>Parameters
No parameters.
Returns
Promise<unknown>
chunks — method signatures
Signatures
(onChunk: (chunk: Uint8Array) => void): Promise<void>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
onChunk | (chunk: Uint8Array) => void | Yes | — |
Returns
Promise<void>
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.