Represents the http options that can be passed to a browser http client.

interface FetchHttpHandlerOptions {
    cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
    credentials?: string;
    keepAlive?: boolean;
    requestInit?: ((httpRequest) => RequestInit);
    requestTimeout?: number;
}

Properties

cache?: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload"

Cache settings for fetch.

credentials?: string

A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL.

keepAlive?: boolean

Whether to allow the request to outlive the page. Default value is false.

There may be limitations to the payload size, number of concurrent requests, request duration etc. when using keepalive in browsers.

These may change over time, so look for up to date information about these limitations before enabling keepalive.

requestInit?: ((httpRequest) => RequestInit)

An optional function that produces additional RequestInit parameters for each httpRequest.

This is applied last via merging with Object.assign() and overwrites other values set from other sources.

Type declaration

    • (httpRequest): RequestInit
    • An optional function that produces additional RequestInit parameters for each httpRequest.

      This is applied last via merging with Object.assign() and overwrites other values set from other sources.

      Parameters

      Returns RequestInit

      Example

      new Client({
      requestHandler: {
      requestInit(httpRequest) {
      return { cache: "no-store" };
      }
      }
      });

Example

new Client({
requestHandler: {
requestInit(httpRequest) {
return { cache: "no-store" };
}
}
});
requestTimeout?: number

The number of milliseconds a request can take before being automatically terminated.