1681-engine / index / ApiClientOptions
Interface: ApiClientOptions ​
Defined in: src/net/ApiClient.ts:37
Properties ​
baseUrl ​
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? ​
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 ​
| Parameter | Type |
|---|---|
body | unknown |
status | number |
Returns ​
fetch? ​
optional fetch?: {
(input, init?): Promise<Response>;
(input, init?): Promise<Response>;
};Defined in: src/net/ApiClient.ts:55
Default the global fetch.
Call Signature ​
(input, init?): Promise<Response>;Parameters ​
| Parameter | Type |
|---|---|
input | URL | RequestInfo |
init? | RequestInit |
Returns ​
Promise<Response>
Call Signature ​
(input, init?): Promise<Response>;Parameters ​
| Parameter | Type |
|---|---|
input | string | URL | Request |
init? | RequestInit |
Returns ​
Promise<Response>
headers? ​
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? ​
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? ​
optional noRefresh?: (path) => boolean;Defined in: src/net/ApiClient.ts:49
Paths a 401 never refreshes for (the login and refresh calls themselves).
Parameters ​
| Parameter | Type |
|---|---|
path | string |
Returns ​
boolean
onError? ​
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 ​
| Parameter | Type |
|---|---|
error | ApiError |
Returns ​
void
onStatus? ​
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? ​
optional timeoutMs?: number;Defined in: src/net/ApiClient.ts:43
Default 10 s; a request may give its own.