Defjs
Core

fetchHandler

Default HTTP transport: perform httpRequest with fetch and return an HttpResponse.

@defjs/core · Function

Signature

function fetchHandler(
  httpRequest: HttpRequest,
  fetchImpl?: FetchHandle,
): Promise<HttpResponse<unknown>>;

The client always uses it; withHTTPHandle only supplies the fetchImpl it calls. Also usable in tests and custom handlers. fetchImpl defaults to the global fetch resolved at send time. It rejects, rather than resolving with a synthetic response, when no response reached the client.

Parameters

Prop

Type

httpRequest HttpRequest

Normalized request (URL, headers, body, signal, progress hooks).

fetchImpl? FetchHandle

Fetch implementation; defaults to global fetch. The library default handle is called as (url, init) while the global is untouched, and its body is read in one piece unless download progress is observed. Any other handle receives a Request and its body is read chunk by chunk.

Returns

Parsed HttpResponse. Rejects when no response reached the client, when reading the body failed, or when an upload observer threw (EXT_OBSERVER_FAILED). Cancellation still wins.

Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao