Skip to main content

Function: fetch()

fetch(input, init?): Promise<Response>

Defined in: src/http/fetch.ts:388

Fetch a resource, returning a standard global Response.

This mirrors the global Fetch API while exposing impers' impersonation and transport options via ImpersRequestInit.

  • Network errors (connection/DNS/SSL/timeout/abort) are re-thrown as TypeError with the original impers exception preserved in cause.
  • 4xx/5xx responses are returned (not rejected), matching Fetch semantics.
  • response.url/response.redirected are not populated (constructor limit).

Parameters​

input​

string | URL | Request

A URL string, URL, or global Request.

init?​

ImpersRequestInit

Standard RequestInit plus impers extensions.

Returns​

Promise<Response>

A global Response.

Example​

const res = await fetch("https://example.com", { impersonate: "chrome124" });
console.log(res.status, await res.text());