@seamapi/http - v2.4.1
    Preparing search index...

    Class SeamHttpRequest<TResponse, TResponseKey>

    A lazy request to the Seam API.

    Creating a SeamHttpRequest does not send anything over the network. The request is sent once execute is called, or when the request is awaited like a Promise, e.g., with await, then, catch, or finally. When the response contains an action attempt, awaiting the request also waits for the action attempt to resolve according to the waitForActionAttempt option.

    Before sending, the request may be inspected with url, pathname, method, params, and body.

    Type Parameters

    • const TResponse
    • const TResponseKey extends keyof TResponse | undefined

    Implements

    Index
    "[toStringTag]": string = 'SeamHttpRequest'

    String tag used by Object.prototype.toString, always SeamHttpRequest.

    • get body(): unknown

      The body sent with the request, if any.

      Returns unknown

    • get method(): Method

      The HTTP request method.

      Returns Method

    • get params(): Record<string, unknown> | undefined

      The query parameters sent with the request, if any.

      Returns Record<string, unknown> | undefined

    • get pathname(): string

      The request pathname, e.g., /devices/get.

      Returns string

    • get responseKey(): TResponseKey

      The key of the API response object containing the response data, or undefined if the endpoint returns an empty response.

      Returns TResponseKey

    • get url(): URL

      The full request URL including any serialized query parameters.

      Returns URL

    • Executes the request and handles any rejection with onrejected. Enables awaiting a SeamHttpRequest like a Promise.

      Type Parameters

      • TResult = never

      Parameters

      • Optionalonrejected: ((reason: unknown) => TResult | PromiseLike<TResult>) | null

      Returns Promise<
          | TResult
          | (
              TResponseKey extends keyof TResponse
                  ? TResponse[TResponseKey]
                  : undefined
          ),
      >

    • Sends the request and returns the response data. If the response contains an action attempt, waits for the action attempt to resolve according to the waitForActionAttempt option.

      Returns Promise<
          TResponseKey extends keyof TResponse
              ? TResponse[TResponseKey]
              : undefined,
      >

    • Sends the request and returns the entire response body without waiting for any action attempt to resolve.

      Returns Promise<TResponse>

    • Executes the request and calls onfinally once the request settles. Enables awaiting a SeamHttpRequest like a Promise.

      Parameters

      • Optionalonfinally: (() => void) | null

      Returns Promise<
          TResponseKey extends keyof TResponse
              ? TResponse[TResponseKey]
              : undefined,
      >