A base class for web api services using the axios http client.

Hierarchy

Constructors

  • Parameters

    • baseURL: string

      The service's base URL including the trailing /

    • controllerName: string

      The service's controllerName

    • Optional tokenFactory: (() => Promise<null | string>)

      Optional factory to set axios instance's token before http calls.'

        • (): Promise<null | string>
        • Returns Promise<null | string>

    Returns BaseService

Properties

axios: AxiosInstance

The axios instance used by this service.

controllerName: any

The name of the controller, used in constructing the axios instance's baseURL.

setBaseUrl: ((baseURL: string) => void)

Type declaration

setToken: ((token: null | string) => void)

Type declaration

    • (token: null | string): void
    • Set the token to use in the service's axios instance

      Parameters

      • token: null | string

        Bearer token or null.

      Returns void