Skip to content

ApiClient

Defined in: src/ui/api-client.ts:68

One product’s API client.

apiUrl(path): string;

Defined in: src/ui/api-client.ts:76

The URL for an API path under the current base.

Parameter Type
path string

string


getApiToken(): string | null;

Defined in: src/ui/api-client.ts:74

The token set by setApiToken, or null.

string | null


query(params): string;

Defined in: src/ui/api-client.ts:85

toQuery, for convenience.

Parameter Type
params Record<string, QueryValue>

string


req<T>(path, init?): Promise<T>;

Defined in: src/ui/api-client.ts:83

Fetch path and parse JSON; an empty body resolves to undefined.

Type Parameter
T
Parameter Type
path string
init? RequestInit

Promise<T>


send(path, init?): Promise<Response>;

Defined in: src/ui/api-client.ts:81

Fetch path and return the raw Response (for blobs, CSV, JWKS…). Throws the configured error class for non-2xx responses.

Parameter Type
path string
init? RequestInit

Promise<Response>


setApiBase(base, opts?): void;

Defined in: src/ui/api-client.ts:70

Point the client at a base URL (a trailing / is dropped), optionally with credentials/fetch.

Parameter Type
base string
opts? ApiClientOptions

void


setApiToken(token): void;

Defined in: src/ui/api-client.ts:72

Attach a portal/viewer token as Authorization: Bearer … on every request (null clears it).

Parameter Type
token string | null

void