Skip to main content

Function: createInstrumentedFetch()

createInstrumentedFetch(options): (input, init?) => Promise<Response>(input, init?) => Promise<Response>

Defined in: web/lib/api/client.ts:368

An instrumented fetch for call sites the generated client cannot cover.

Parameters​

options​

Whether the request should carry the user's session

authenticated​

boolean

Returns​

Function

A fetch that adds correlation headers, logs, and throws APIError

MDN Reference

Parameters​

input​

URL | RequestInfo

init?​

RequestInit

Returns​

Promise<Response>

MDN Reference

Parameters​

input​

string | URL | Request

init?​

RequestInit

Returns​

Promise<Response>

Remarks​

The generated client routes every call through createFetchHandler, which is where request IDs, W3C traceparent headers, structured logging, Faro reporting and APIError all come from. A handful of call sites cannot use the generated client — the admin surface builds its own service-auth token per NSID — and those were calling fetch directly, so admin requests carried no trace headers and were invisible in tracing, and their failures surfaced as bare Error rather than APIError.

This gives them the same pipeline. Callers supplying their own Authorization header should pass authenticated: false, since the header they set is preserved and the session lookup would only duplicate work.