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.
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 thehttpOptions
at allfetch
APIclient: 'fetch-h2'
fetch-h2
module for HTTP/2 requestsclient: 'custom'
Fetcher
implementation to the clientHTTP/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 withfetch
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 modifyfetch
'sRequestInit
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