Optional
closeThis is an optional method which may destroy any resources, if necessary (open connections, etc.).
Called on DataAPIClient.close.
Makes the actual API request for the given request information. Please take all request information into account when making the request, or you may run into errors or unexpected behavior from your implementation.
Be sure to check out FetcherRequestInfo and FetcherResponseInfo for more information on the input and output objects.
content-type
, user-agent
, Authorization
, etc., headers are already setGET
, POST
, DELETE
, but more may be required in the futureAbortSignal
or another valid timeout mechanism.axios
's timeout
optioninfo.mkTimeoutError()
instead.Object.fromEntries(resp.headers.entries())
await resp.text()
info.forceHttp1
is true
, ensure the request only uses HTTP/1[.1]
, even if HTTP/2
is supported.HTTP/2
extraLogInfo
stdout/stderr
LoggingOutputevent
outputThe request information (url, body, method, headers, etc.)
Overview
A simple adapter interface that allows you to define a custom HTTP request strategy that
astra-db-ts
may use to make requests.See FetchH2 and FetchNative on the
astra-db-ts
GitHub repo for example implementations.Disclaimer
Ensure that you take into account all request information when making the request, or you may run into errors or unexpected behavior from your implementation.
Thorough testing is heavily recommended to ensure that your implementation works as expected.
If desired, the
astra-db-ts
repo may be forked and have its test suite be run against your custom implementation to ensure complete compatibility.Use cases
You may want to use a custom
Fetcher
implementation if:Implementation
It is heavily recommended that you take a look at the aforementioned implementations to get a better idea of how to implement your own.
The basic idea is that you create a class or object implementing the
Fetcher
interface, and pass it tohttpOptions
in theDataAPIClient
constructor.See the Fetcher.fetch and Fetcher.close methods for information on how to implement those methods, along with a checklist of things to consider.
Example
See