global.Response
A fetch response, for checking its status and reading its body whole or as it streams in.
Utilização
Measure an operation without relying on wall-clock changes.
Este tipo é usado por 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);Declaração do tipo
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>;
}Membros 11
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
oksó de leitura | boolean | Sim | — |
statussó de leitura | number | Sim | — |
statusTextsó de leitura | string | Sim | — |
urlsó de leitura | string | Sim | The URL that answered, after redirects. |
headerssó de leitura | Headers | Sim | — |
bodyUsedsó de leitura | boolean | Sim | — |
arrayBuffer | () => Promise<ArrayBuffer> | Sim | — |
bytes | () => Promise<Uint8Array> | Sim | — |
text | () => Promise<string> | Sim | — |
json | () => Promise<unknown> | Sim | — |
chunks | (onChunk: (chunk: Uint8Array) => void) => Promise<void> | Sim | 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 — assinaturas de método
Assinaturas
(): Promise<ArrayBuffer>Parâmetros
Sem parâmetros.
Devolve
Promise<ArrayBuffer>
bytes — assinaturas de método
Assinaturas
(): Promise<Uint8Array>Parâmetros
Sem parâmetros.
Devolve
Promise<Uint8Array<ArrayBufferLike>>
text — assinaturas de método
Assinaturas
(): Promise<string>Parâmetros
Sem parâmetros.
Devolve
Promise<string>
json — assinaturas de método
Assinaturas
(): Promise<unknown>Parâmetros
Sem parâmetros.
Devolve
Promise<unknown>
chunks — assinaturas de método
Assinaturas
(onChunk: (chunk: Uint8Array) => void): Promise<void>Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
onChunk | (chunk: Uint8Array) => void | Sim | — |
Devolve
Promise<void>
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.