Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ExpressClient<API>

Basic AJAX class than can be used in Node or the browser. Essentially just wraps around some axios methods and provides the proper typing based on the given HttpInterface, so that no requests are malformed.

Type parameters

Hierarchy

  • ExpressClient

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

host

host: string

The base hostname/URL that the client should send its requests to.

Static axios

axios: AxiosStatic = (typeof window !== 'undefined') && window.axios ? window.axios : null

Reference to the axios library. If the client is running in the browser, it is assumed that axios will be available on window.

Methods

delete

  • delete<EP>(endpoint: EP, args: API["delete"][EP]["args"], config?: AxiosRequestConfig): AxiosPromise<API["delete"][EP]["return"]>
  • Sends a DELETE request to the given endpoint. Note that since DELETE requests cannot have a body, the args are passed as query parameters.

    Type parameters

    • EP: keyof API["delete"]

    Parameters

    • endpoint: EP
    • args: API["delete"][EP]["args"]
    • Optional config: AxiosRequestConfig

    Returns AxiosPromise<API["delete"][EP]["return"]>

get

  • get<EP>(endpoint: EP, args: API["get"][EP]["args"], config?: AxiosRequestConfig): AxiosPromise<API["get"][EP]["return"]>
  • Sends a GET request to the given endpoint. Note that since GET requests cannot have a body, the args are passed as query parameters.

    Type parameters

    • EP: keyof API["get"]

    Parameters

    • endpoint: EP
    • args: API["get"][EP]["args"]
    • Optional config: AxiosRequestConfig

    Returns AxiosPromise<API["get"][EP]["return"]>

patch

  • patch<EP>(endpoint: EP, args: API["patch"][EP]["args"], config?: AxiosRequestConfig): AxiosPromise<API["patch"][EP]["return"]>
  • Sends a PATCH request to the given endpoint with the given arguments.

    Type parameters

    • EP: keyof API["patch"]

    Parameters

    • endpoint: EP
    • args: API["patch"][EP]["args"]
    • Optional config: AxiosRequestConfig

    Returns AxiosPromise<API["patch"][EP]["return"]>

post

  • post<EP>(endpoint: EP, args: API["post"][EP]["args"], config?: AxiosRequestConfig): AxiosPromise<API["post"][EP]["return"]>
  • Sends a POST request to the given endpoint with the given arguments.

    Type parameters

    • EP: keyof API["post"]

    Parameters

    • endpoint: EP
    • args: API["post"][EP]["args"]
    • Optional config: AxiosRequestConfig

    Returns AxiosPromise<API["post"][EP]["return"]>

put

  • put<EP>(endpoint: EP, args: API["put"][EP]["args"], config?: AxiosRequestConfig): AxiosPromise<API["put"][EP]["return"]>
  • Sends a PUT request to the given endpoint with the given arguments.

    Type parameters

    • EP: keyof API["put"]

    Parameters

    • endpoint: EP
    • args: API["put"][EP]["args"]
    • Optional config: AxiosRequestConfig

    Returns AxiosPromise<API["put"][EP]["return"]>

request

  • request<M, EP>(endpoint: EP, config: AxiosRequestConfig & object): AxiosPromise<API[M][EP]["return"]>
  • General HTTP request method.

    Type parameters

    Parameters

    • endpoint: EP
    • config: AxiosRequestConfig & object

    Returns AxiosPromise<API[M][EP]["return"]>

Generated using TypeDoc