@seamapi/http - v2.5.0
    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'
    • get body(): unknown

      Returns unknown

    • get method(): Method

      Returns Method

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

      Returns Record<string, unknown> | undefined

    • get pathname(): string

      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

    • Attaches a callback for only the rejection of the Promise.

      Type Parameters

      • TResult = never

      Parameters

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

        The callback to execute when the Promise is rejected.

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

      A Promise for the completion of the callback.

    • 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>

    • Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

      Parameters

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

        The callback to execute when the Promise is settled (fulfilled or rejected).

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

      A Promise for the completion of the callback.

    • Attaches callbacks for the resolution and/or rejection of the Promise.

      Type Parameters

      Parameters

      • Optionalonfulfilled:
            | (
                (
                    value: TResponseKey extends keyof TResponse
                        ? TResponse[TResponseKey]
                        : undefined,
                ) => TResult1
                | PromiseLike<TResult1>
            )
            | null

        The callback to execute when the Promise is resolved.

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

        The callback to execute when the Promise is rejected.

      Returns Promise<TResult1 | TResult2>

      A Promise for the completion of which ever callback is executed.