Transport layer that use browser fetch.

Implements

Constructors

Properties

chunkCombiner: ChunkCombiner = ...
requestDecorator: (
    request: RequestInit,
    options: SendOptions,
    url: string,
) => void = ...

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)
}
}

Methods

  • Sends requestBody and returns response chunks in an async iterable that can be easily consumed in an for-await loop.

    Parameters

    • path: string

      HTTP request path

    • body: string
    • options: SendOptions

      send options

    Returns AsyncIterableIterator<Uint8Array>

    async iterable