Skip to main content

APIClient<C>

A base class for API clients used in ISP Nexus.

Extends​

  • EventTarget

Type Parameters​

Type ParameterDefault type
C extends APIClientConfigAPIClientConfig

Implements​

  • AsyncDisposable

Constructors​

new APIClient()​

new APIClient<C>(config): APIClient<C>

Parameters​

ParameterType
configC

Returns​

APIClient<C>

Overrides​

EventTarget.constructor

Properties​

axios​

readonly axios: AxiosInstance | AxiosCacheInstance;

The Axios instance for the API client.


config​

readonly config: C;

logger​

readonly logger: IRuntimeLogger<string[]>;

The prefixed logger for the API client.

Accessors​

$cooldown​

get $cooldown(): Promise<void>

Returns​

Promise<void>

Methods​

[asyncDispose]()​

asyncDispose: Promise<void>

Returns​

Promise<void>

Implementation of​

AsyncDisposable.[asyncDispose]


addEventListener()​

addEventListener(
type,
listener,
options?): void

Adds a new handler for the type event. Any given listener is added only once per type and per capture option value.

If the once option is true, the listener is removed after the next time a type event is dispatched.

The capture option is not used by Node.js in any functional way other than tracking registered event listeners per the EventTarget specification. Specifically, the capture option is used as part of the key when registering a listener. Any individual listener may be added once with capture = false, and once with capture = true.

Parameters​

ParameterType
typestring
listenerEventListener | EventListenerObject
options?boolean | AddEventListenerOptions

Returns​

void

Inherited from​

EventTarget.addEventListener


dispatchEvent()​

dispatchEvent(event): boolean

Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

Parameters​

ParameterType
eventEvent

Returns​

boolean

Inherited from​

EventTarget.dispatchEvent


fetch()​

fetch<T>(options): Promise<AxiosResponse<T, any>>

Type Parameters​

Type Parameter
T

Parameters​

ParameterType
optionsAxiosRequestConfig<any>

Returns​

Promise<AxiosResponse<T, any>>


removeEventListener()​

removeEventListener(
type,
listener,
options?): void

Removes the event listener in target's event listener list with the same type, callback, and options.

Parameters​

ParameterType
typestring
listenerEventListener | EventListenerObject
options?boolean | EventListenerOptions

Returns​

void

Inherited from​

EventTarget.removeEventListener


setCooldown()​

protected setCooldown(nextCooldown): void

Parameters​

ParameterType
nextCooldownnumber

Returns​

void


toString()​

toString(): string

Returns a string representation of an object.

Returns​

string


updateCooldownAfterResponse()​

protected updateCooldownAfterResponse(response): AxiosResponse<any, any> | CacheAxiosResponse<any, any>

Parameters​

ParameterType
responseAxiosResponse<any, any> | CacheAxiosResponse<any, any>

Returns​

AxiosResponse<any, any> | CacheAxiosResponse<any, any>