Member Junction
    Preparing search index...

    A configured HTTP client — the replacement for axios.create(...).

    Holds a base URL, default headers, a timeout, and the HttpClientOptions hooks that stand in for axios interceptors. Construct one per upstream API, typically behind a lazy getter on a provider base class so the cost is paid only when that provider is actually used.

    Instances are stateless apart from their options and safe to share across concurrent requests. Nothing is cached between calls, so a client whose OnRequest reads a token always sends the current one.

    private _client: HttpClient | null = null;

    protected get httpClient(): HttpClient {
    if (!this._client) {
    this._client = new HttpClient({
    BaseURL: 'https://graph.facebook.com/v18.0',
    Timeout: 30000,
    Headers: { Accept: 'application/json' },

    // Runs before every attempt, so a refreshed token is picked up automatically.
    OnRequest: (config) => ({
    ...config,
    Query: { ...config.Query, access_token: this.getAccessToken() },
    }),

    // Bounded by MaxRetries (default 3).
    OnRetry: async (error) => {
    if (error.Status !== 429) return false;
    await this.handleRateLimit(60);
    return true;
    },
    });
    }
    return this._client;
    }

    // Then, at the call sites:
    const response = await this.httpClient.Get<FacebookPagedResponse<Post>>('/me/feed');
    return response.Data.data;
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    Methods

    • Sends a DELETE request through this client.

      Type Parameters

      • T = unknown

        the expected shape of the parsed response body.

      Parameters

      • url: string

        absolute URL, or a path resolved against the client's BaseURL.

      • Optionalconfig: Omit<HttpRequestConfig, "Url" | "Method" | "Body">

        optional per-request settings, merged over the client's defaults.

      Returns Promise<HttpResponse<T>>

      the HttpResponse.

      on a non-2xx status, timeout, cancellation, or transport failure.

    • Sends a GET request through this client.

      Type Parameters

      • T = unknown

        the expected shape of the parsed response body.

      Parameters

      • url: string

        absolute URL, or a path resolved against the client's BaseURL.

      • Optionalconfig: Omit<HttpRequestConfig, "Url" | "Method" | "Body">

        optional per-request settings, merged over the client's defaults.

      Returns Promise<HttpResponse<T>>

      the HttpResponse.

      on a non-2xx status, timeout, cancellation, or transport failure.

    • Sends a HEAD request through this client. ResponseType is forced to none, so Data is always null.

      Type Parameters

      • T = unknown

        the expected shape of the parsed response body.

      Parameters

      • url: string

        absolute URL, or a path resolved against the client's BaseURL.

      • Optionalconfig: Omit<HttpRequestConfig, "Url" | "Method" | "Body">

        optional per-request settings, merged over the client's defaults.

      Returns Promise<HttpResponse<T>>

      the HttpResponse.

      on a non-2xx status, timeout, cancellation, or transport failure.

    • Sends a PATCH request through this client. Body handling matches HttpPost.

      Type Parameters

      • T = unknown

        the expected shape of the parsed response body.

      Parameters

      • url: string

        absolute URL, or a path resolved against the client's BaseURL.

      • Optionalbody: unknown

        the request body.

      • Optionalconfig: Omit<HttpRequestConfig, "Url" | "Method" | "Body">

        optional per-request settings, merged over the client's defaults.

      Returns Promise<HttpResponse<T>>

      the HttpResponse.

      on a non-2xx status, timeout, cancellation, or transport failure.

    Post

    • Post<T = unknown>(
          url: string,
          body?: unknown,
          config?: Omit<HttpRequestConfig, "Url" | "Method" | "Body">,
      ): Promise<HttpResponse<T>>

      Sends a POST request through this client. Body handling matches HttpPost.

      Type Parameters

      • T = unknown

        the expected shape of the parsed response body.

      Parameters

      • url: string

        absolute URL, or a path resolved against the client's BaseURL.

      • Optionalbody: unknown

        the request body.

      • Optionalconfig: Omit<HttpRequestConfig, "Url" | "Method" | "Body">

        optional per-request settings, merged over the client's defaults.

      Returns Promise<HttpResponse<T>>

      the HttpResponse.

      on a non-2xx status, timeout, cancellation, or transport failure.

    • Sends a PUT request through this client. Body handling matches HttpPost.

      Type Parameters

      • T = unknown

        the expected shape of the parsed response body.

      Parameters

      • url: string

        absolute URL, or a path resolved against the client's BaseURL.

      • Optionalbody: unknown

        the request body.

      • Optionalconfig: Omit<HttpRequestConfig, "Url" | "Method" | "Body">

        optional per-request settings, merged over the client's defaults.

      Returns Promise<HttpResponse<T>>

      the HttpResponse.

      on a non-2xx status, timeout, cancellation, or transport failure.

    • Sends a request using this client's defaults and hooks. Every other method on the class delegates here.

      Per-request values win over client defaults, except Headers, which are merged key-by-key so one request can override a single default header without discarding the rest. OnRequest then gets the last word on the merged config.

      Type Parameters

      • T = unknown

        the expected shape of the parsed response body.

      Parameters

      • config: HttpRequestConfig

        per-request configuration, merged over the client's defaults.

      Returns Promise<HttpResponse<T>>

      the HttpResponse.

      when the request fails and OnRetry does not ask for another attempt, or once MaxRetries is exhausted.

      when ValidateUrl is enabled and the target resolves to a blocked address. Never retried.