Skip to content

ApiClient

Core API Client for handling HTTP requests to the WebbiOS API. This class wraps the native fetch API, injects authentication headers, and handles global 401 Unauthorized responses.

new ApiClient(options?): ApiClient

Initializes a new ApiClient instance.

WebbiSDKOptions = {}

Initialization configuration.

ApiClient

delete(path, options?): Promise<any>

Performs an HTTP DELETE request.

string

The relative API path.

RequestInit

Additional Fetch options.

Promise<any>

The parsed JSON response.


fetch(path, options?): Promise<any>

Performs a raw HTTP request to the configured API endpoint.

string

The relative API path (e.g., /auth/me).

RequestInit = {}

Standard Fetch API RequestInit options.

Promise<any>

A promise resolving to the parsed JSON response.

Will throw an Error if the response status is not OK (2xx).


get(path, options?): Promise<any>

Performs an HTTP GET request.

string

The relative API path.

RequestInit

Additional Fetch options.

Promise<any>

The parsed JSON response.


post(path, body, options?): Promise<any>

Performs an HTTP POST request.

string

The relative API path.

any

The request payload (will be stringified as JSON).

RequestInit

Additional Fetch options.

Promise<any>

The parsed JSON response.


put(path, body, options?): Promise<any>

Performs an HTTP PUT request.

string

The relative API path.

any

The request payload (will be stringified as JSON).

RequestInit

Additional Fetch options.

Promise<any>

The parsed JSON response.


setRefreshCallback(cb): void

Registers a callback that will be triggered when an API request fails with a 401 Unauthorized status code.

() => void

The callback function.

void


setToken(token): void

Sets or updates the JWT access token for subsequent requests.

string

The JWT string.

void