Request options supported by apprt-request. This is an extension of the Browser's native fetch options.

See also the init parameter of apprt-fetch for a list of all options provided by the browser.

interface ApprtRequestInit {
    checkStatus?: boolean;
    context?: Record<string | symbol, unknown>;
    preventCache?: boolean;
    proxyMode?: ProxyMode;
    query?: string | URLSearchParams | Record<string, any>;
    queryTransport?: "url" | "form";
    supportsPostSwitching?: boolean;
    timeoutMillis?: number;
}

Hierarchy

  • RequestInit
    • ApprtRequestInit

Properties

checkStatus?: boolean

If true, throws an error if the response is not ok, i.e. if the response status code is not between 200 and 299.

Default: false.

context?: Record<string | symbol, unknown>

Arbitrary settings that can be read by interceptors.

preventCache?: boolean

Ensures that the target resource is fresh from the server. This is a shorthand for the fetch option cache: "no-store".

proxyMode?: ProxyMode

By default, requests will use a proxy only if a proxy rule matches.

If "force-on" is configured, the request will always use a proxy server, falling back to the default proxy if no proxy rule matches. An error will be thrown if no default proxy is configured in this case.

If "force-off" is used, no proxy server will be used, even if a proxy rule would match.

query?: string | URLSearchParams | Record<string, any>

Convenience option to add additional query arguments to the request. The transport of the given value depends on the value of queryTransport. By default, query arguments passed here will be appended to the query part of the request URL.

queryTransport?: "url" | "form"

Configures the way the query value is transported to the server.

  • Use the value "url" (the default) to append the query to the request url.
  • Use "form" instead to set the request body to query (encoded as application/x-www-form-urlencoded). No other request body should be specified in this case.

If query is a string, then it should already be URL encoded. If query is an instance of URLSearchParams, all params will simply be copied. If query is a plain object, all properties will be serialized by calling objectToQuery() from apprt-core/url-utils.

Default: "url".

supportsPostSwitching?: boolean

If set to true, GET requests with very long URLs (see Config.maxUrlLength) will automatically switch to POST requests.

Default: false

timeoutMillis?: number

Time in milliseconds after which the fetch aborts with a timeout. Defaults to the timeout settings on the global configuration object: config.