Options
All
  • Public
  • Public/Protected
  • All
Menu

HTTPClient is a wrapper around a BaseHTTPClient It takes care of setting the proper "Accept" header and of decoding the JSON outputs.

Hierarchy

  • HTTPClient

Index

Constructors

Properties

Methods

  • delete(relativePath: string, data: any, requestHeaders?: Record<string, string>): Promise<HTTPClientResponse>
  • Send a DELETE request. If no content-type present, adds the header "content-type: application/json" and data is serialized in JSON (if not empty)

    Parameters

    • relativePath: string
    • data: any
    • requestHeaders: Record<string, string> = {}

    Returns Promise<HTTPClientResponse>

  • Send a GET request.

    Parameters

    • relativePath: string

      The path of the request.

    • Optional query: Query<any>

      An object containing the query parameters of the request.

    • requestHeaders: Record<string, string> = {}

      An object containing additional request headers to use.

    • jsonOptions: JSONOptions = {}

      Options object to use to decode JSON responses. See utils.parseJSON for the options available.

    Returns Promise<HTTPClientResponse>

    Response object.

  • post(relativePath: string, data: any, requestHeaders?: Record<string, string>): Promise<HTTPClientResponse>
  • Send a POST request. If no content-type present, adds the header "content-type: application/json" and data is serialized in JSON (if not empty)

    Parameters

    • relativePath: string
    • data: any
    • requestHeaders: Record<string, string> = {}

    Returns Promise<HTTPClientResponse>

  • parseJSON(text: string, status: number, jsonOptions?: JSONOptions): any
  • Parse JSON using either the built-in JSON.parse or utils.parseJSON depending on whether jsonOptions are provided or not

    Parameters

    • text: string

      JSON data

    • status: number

      Status of the response (used in case parseJSON fails)

    • jsonOptions: JSONOptions = {}

      Options object to use to decode JSON responses. See utils.parseJSON for the options available.

    Returns any

  • prepareResponseError(err: any): any
  • Prepare an error with a response (the type of errors BaseHTTPClient are supposed to throw) by adding the status and preparing the internal response

    Parameters

    • err: any

    Returns any

  • serializeData(data: object, requestHeaders: Record<string, string>): Uint8Array
  • Serialize the data according to the requestHeaders Assumes that requestHeaders contain a key "content-type" If the content-type is "application/json", data is JSON serialized Otherwise, data needs to be either an UTF-8 string that is converted to an Uint8Array or an Uint8Array

    Parameters

    • data: object
    • requestHeaders: Record<string, string>

    Returns Uint8Array

Generated using TypeDoc