Interface CustomHttpClientOptions

Overview

Allows you to use your own custom HTTP request strategy, rather than the default fetch or fetch-h2 implementations.

It may also be used to wrap an existing Fetcher implementation (i.e. FetchNative or FetchH2) with your own custom logic or to add extra logging/debug information.

Implementation Details

See the Fetcher classes for details on implementing your own custom fetcher, along with a checklist of things to consider.

Be wary of the potential for errors or unexpected behavior if you do not take all request information into account when making the request, or make some other mistake with the fetcher.

Example

class CustomFetcher implements Fetcher {
async fetch(info: FetcherRequestInfo): Promise<FetcherResponseInfo> {
// Custom fetch implementation
}
}

const client = new DataAPIClient({
httpOptions: { client: 'custom', fetcher: new CustomFetcher() },
});
Examples

For advanced examples & more information, see the examples/customize-http directory in the astra-db-ts repository

See

  • Fetcher
  • HttpOptions
interface CustomHttpClientOptions {
    client: "custom";
    fetcher: Fetcher;
}

Properties

Properties

client: "custom"

Tells the Data API client to use your custom "fetcher" for making HTTP requests.

See HttpOptions for the other options available.

fetcher: Fetcher

The custom "fetcher" to use.