Skip to content

1681-engine / index / ApiClientOptions

Interface: ApiClientOptions ​

Defined in: src/net/ApiClient.ts:37

Properties ​

baseUrl ​

ts
baseUrl: string | ((path) => string);

Defined in: src/net/ApiClient.ts:39

The server's origin (https://host), or one chosen per path (accounts on one server, the game on another).


describe? ​

ts
optional describe?: (body, status) => ApiErrorInfo;

Defined in: src/net/ApiClient.ts:45

Turns a failed answer's parsed body into its code, message and details (a game rendering its own messages).

Parameters ​

ParameterType
bodyunknown
statusnumber

Returns ​

ApiErrorInfo


fetch? ​

ts
optional fetch?: {
  (input, init?): Promise<Response>;
  (input, init?): Promise<Response>;
};

Defined in: src/net/ApiClient.ts:55

Default the global fetch.

Call Signature ​

ts
(input, init?): Promise<Response>;

MDN Reference

Parameters ​
ParameterType
inputURL | RequestInfo
init?RequestInit
Returns ​

Promise<Response>

Call Signature ​

ts
(input, init?): Promise<Response>;

MDN Reference

Parameters ​
ParameterType
inputstring | URL | Request
init?RequestInit
Returns ​

Promise<Response>


headers? ​

ts
optional headers?: () => Readonly<Record<string, string>>;

Defined in: src/net/ApiClient.ts:41

Headers sent with every request (a client version, a platform), asked afresh each time.

Returns ​

Readonly<Record<string, string>>


networkMessage? ​

ts
optional networkMessage?: string | (() => string);

Defined in: src/net/ApiClient.ts:47

The message of a request that got no answer (default 'Cannot reach the server.').


noRefresh? ​

ts
optional noRefresh?: (path) => boolean;

Defined in: src/net/ApiClient.ts:49

Paths a 401 never refreshes for (the login and refresh calls themselves).

Parameters ​

ParameterType
pathstring

Returns ​

boolean


onError? ​

ts
optional onError?: (error) => void;

Defined in: src/net/ApiClient.ts:51

Called with every failed answer before it is thrown (an "update required" gate reading status or code).

Parameters ​

ParameterType
errorApiError

Returns ​

void


onStatus? ​

ts
optional onStatus?: Readonly<Record<number, (error) => void>>;

Defined in: src/net/ApiClient.ts:53

Called for answers with one status before it is thrown: { 426: (e) => showUpdate(e.details) }.


timeoutMs? ​

ts
optional timeoutMs?: number;

Defined in: src/net/ApiClient.ts:43

Default 10 s; a request may give its own.

Released under the MIT License.