• Public
  • Public/Protected
  • All

Class JSONRequest<Data, Body>

Base abstract class for JSON requests.

Data: The type returned from the do() method

Body: The structure of the response's body

Type parameters

  • Data = Record<string, any>

  • Body = Data | Uint8Array





Methods JSONRequest


  • Type parameters

    • Data = Record<string, any>

    • Body = Uint8Array | Data


    • client: HTTPClient

      HTTPClient object.

    • Optional intDecoding: IntDecoding

      The method to use for decoding integers from this request's response. See the setIntDecoding method for more details.

    Returns JSONRequest<Data, Body>


intDecoding: IntDecoding
query: Record<string, any>

JSONRequest Methods

  • do(headers?: Record<string, any>): Promise<Data>
  • Execute the request.


    • headers: Record<string, any> = {}

      Additional headers to send in the request. Optional.

    Returns Promise<Data>

    A promise which resolves to the response data.

  • path(): string
  • prepare(body: Body): Data
  • Prepare a JSON response before returning it.

    Use this method to change and restructure response data as needed after receiving it from the do() method.


    • body: Body

      Response body received

    Returns Data

  • Configure how integers in this request's JSON response will be decoded.

    The options are:

    • "default": Integers will be decoded according to JSON.parse, meaning they will all be Numbers and any values greater than Number.MAX_SAFE_INTEGER will lose precision.
    • "safe": All integers will be decoded as Numbers, but if any values are greater than Number.MAX_SAFE_INTEGER an error will be thrown.
    • "mixed": Integers will be decoded as Numbers if they are less than or equal to Number.MAX_SAFE_INTEGER, otherwise they will be decoded as BigInts.
    • "bigint": All integers will be decoded as BigInts.


    • method: IntDecoding

      The method to use when parsing the response for this request. Must be one of "default", "safe", "mixed", or "bigint".

    Returns JSONRequest<Data, Body>

Generated using TypeDoc