Class APIClient

An API client for the application to use. What makes this service special is that it formats received errors using the _HTTPError class, and as fetch client, it uses the HTTP service, allowing the application to to internally handle all the requests and responses.

The only reason to use the class directly is if you want to subclass it, as you would normally just register the apiClientProvider.

Hierarchy

  • APIClient
    • APIClient

Constructors

Properties

_HTTPError: typeof HTTPError

The class to generate possible errors in the requests.

_apiConfig: APIClientConfig

The configuration of the API it uses.

_http: HTTP

The service that makes the requests to the API.

Accessors

Methods

  • Tries to obtain a message from an error caused on a failed request.

    Parameters

    • response: unknown

      The response from the failed request.

    Returns string

  • Generates an _HTTPError from the response of a failed request.

    Type Parameters

    • ResponseType extends ErrorResponse

    Parameters

    • response: ResponseType

      The response from the failed request.

    • status: number

      The status code of the response.

    Returns Error

Generated using TypeDoc