Options
All
  • Public
  • Public/Protected
  • All
Menu

A rest manager for the client

Hierarchy

  • Rest

Index

Constructors

Properties

client: Client

The client that instantiated this class

queue: AsyncQueue = ...

A queue for the requests

requests: APIRequest[] = []

All requests that have been made so far

requestsPerSecond: number = 0

Number of requests done in the last second

requestsPerSecondResetAt: number = ...

When the requests per second were last reset

Methods

  • get<T>(path: `/${string}`, options?: Omit<RequestOptions, "body">, retry?: boolean): Promise<T>
  • Make a GET request to the API.

    Type Parameters

    • T = null | Json

      The return type that should be used by the function

    Parameters

    • path: `/${string}`

      The path to request

    • Optional options: Omit<RequestOptions, "body">

      Other options for this request

    • Optional retry: boolean

      If the request should be retried in case of a 5xx response

    Returns Promise<T>

    • The JSON data received from the API or null if no data was received
  • request<T>(path: `/${string}`, method: "GET", options?: Omit<RequestOptions, "body">, retry?: boolean): Promise<T>
  • request<T>(path: `/${string}`, method: "DELETE" | "PATCH" | "POST" | "PUT", options?: RequestOptions, retry?: boolean): Promise<T>
  • Make a request to the API.

    Type Parameters

    • T = null | Json

      The return type that should be used by the function

    Parameters

    • path: `/${string}`

      The path to request

    • method: "GET"

      The method of the request

    • Optional options: Omit<RequestOptions, "body">

      Other options for this request

    • Optional retry: boolean

      If the request should be retried in case of a 5xx response

    Returns Promise<T>

    The JSON data received from the API or null if no data was received

  • Type Parameters

    Parameters

    • path: `/${string}`
    • method: "DELETE" | "PATCH" | "POST" | "PUT"
    • Optional options: RequestOptions
    • Optional retry: boolean

    Returns Promise<T>

Generated using TypeDoc