Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

  • new BaseService(baseURL: string, controllerName: string, tokenFactory?: undefined | (() => Promise<string | null>)): BaseService
  • Parameters

    • baseURL: string

      The service's [[baseURL]] including the trailing /

    • controllerName: string

      The service's controllerName

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

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

    Returns BaseService

Properties

Protected axios

axios: AxiosInstance

The axios instance used by this service.

Private controllerName

controllerName: string

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

Methods

setBaseUrl

  • setBaseUrl(baseURL: string): void

setToken

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

    Parameters

    • token: string | null

      Bearer token or null.

    Returns void