RequestDecorator allows to modify requests before sending.
The following example shows a function that adds gzip compression of requests using pako.js.
const client = new InfluxDB({url: 'http://a'})
client.transport.requestDecorator = function(request, options) {
const body = request.body
if (
typeof body === 'string' &&
options.gzipThreshold !== undefined &&
body.length > options.gzipThreshold
) {
request.headers['content-encoding'] = 'gzip'
request.body = pako.gzip(body)
}
}
Sends requestBody and returns response chunks in an async iterable
that can be easily consumed in an for-await
loop.
HTTP request path
send options
async iterable
Sends data to the server and receives decoded result. The type of the result depends on response's content-type (deserialized json, text).
HTTP request path
send options
Optional
responseStarted: ResponseStartedFnresponse data
Send data to the server and receive communication events via callbacks.
HTTP request path
send options
Optional
callbacks: Partial<CommunicationObserver<Uint8Array>>communication callbacks to received data in Uint8Array
Transport layer that use browser fetch.