A class that can send a request compatible with API-X servers.

Making API-X Requests

Other

Working with HTTP Cookies

Working with HTTP Headers

Making API-X Requests

  • Sends the request to an API-X API server.

    Returns Promise<ApiXResponse>

    The response of the request.

    Instances of Error if the request fails and the API-X backend does not have a response object.

    Note: Sending the same request more than once will cause it to fail as API-X backends do not accept repeat requests. Additionally, if the request is 'too old', it may fail. The API-X server determines what 'too old' means. This is to deter keeping request objects for too long as they should be destroyed quickly for security reasons.

  • Sends a request to an API-X API server.

    Parameters

    • request: ApiXRequest

      The request that is sent to the server.

    Returns Promise<ApiXResponse>

    The response of the request.

    Instances of Error if the request fails and the API-X backend does not have a response object.

    Note: Sending the same request more than once will cause it to fail as API-X backends do not accept repeat requests. Additionally, if the request is 'too old', it may fail. The API-X server determines what 'too old' means. This is to deter keeping request objects for too long as they should be destroyed quickly for security reasons.

Other

The HTTP Body to send with the request, if any.

httpMethod: ApiXHttpMethod

The HTTP Method to use with the request.

url: URL

The URL to which the request will be made.

Working with HTTP Cookies

  • get cookies(): Record<string, string>
  • Gets the current cookies as a record.

    Returns Record<string, string>

    A record of cookie name-value pairs.

  • Adds a single cookie.

    Parameters

    • name: string

      The name of the cookie.

    • value: string

      The value of the cookie.

    Returns void

  • Gets the value of a cookie.

    Parameters

    • name: string

      The name of the cookie (case-sensitive).

    Returns undefined | string

    The value of the cookie or undefined.

  • Removes a cookie by name.

    Parameters

    • name: string

      The name of the cookie to remove.

    Returns void

  • Sets multiple cookies at once. This method will overwrite cookies if needed, but it will keep existing ones that don't conflict with newly set ones.

    Parameters

    • cookies: Record<string, string>

      A record of cookie name-value pairs to set.

    Returns void

Working with HTTP Headers

  • get headers(): Record<string, string>
  • The HTTP headers in the request, excluding read-protected headers.

    These will not include any headers that contain sensitive information such as request signature.

    Returns Record<string, string>

  • Returns the value of any unprotected or write-protected header in the request.

    This will not get the Cookie unless it's set with setHeader. To get a cookie, use getCookie or cookies.

    Parameters

    • name: string

      The case-insensitive name of the header.

    Returns undefined | string

    The value of the header or undefined.

    Error error if attempting to access a protected header.

  • Sets a header in the request. This will override any non-protected header in the request.

    Parameters

    • name: string

      The header name (e.g.: X-Custom-Header). The header will be set lowercased.

    • value: string

      The value in the header.

    Returns void

  • Unsets a header in the request. This will override any non-protected header in the request.

    Parameters

    • name: string

      The header name (e.g.: X-Custom-Header). Case-insensitive.

    Returns void