Type alias HttpOptions

Overview

The options available for the DataAPIClient related to making HTTP requests.

There are three different behaviours for setting the client:

  • client: 'fetch' or not setting the httpOptions at all
    • This will use the native fetch API
  • client: 'fetch-h2'
    • This will use the provided fetch-h2 module for HTTP/2 requests
  • client: 'custom'
    • This will allow you to pass a custom Fetcher implementation to the client
HTTP/2 support

fetch-h2 is a fetch implementation that supports HTTP/2, and may offer notable performance gains.

However, it is not included in the SDK by default (for compatability reasons); the module will need to be manually provided by the user.

Luckily, it takes only a couple of easy steps. See FetchH2HttpClientOptions for more information.

Alternatively, if using Node.js, you may use a custom Undici Dispatcher configured to use HTTP/2 with fetch instead. See below for more information.

Using your own Fetcher implementation

custom may be used for advanced users who want to use their own fetch implementation, or modify an existing one to suit their needs.

For example, if you want to use a custom HTTP Agent/Dispatcher, or modify fetch's RequestInit in any way, you can easily do so by extending the FetchNative class.

See CustomHttpClientOptions for more information.

Examples & more info

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