matrix-js-sdk

    Interface BaseRequestOpts

    Options object for FetchHttpApi.requestOtherUrl.

    interface BaseRequestOpts {
        abortSignal?: AbortSignal;
        headers?: Record<string, string>;
        json?: boolean;
        keepAlive?: boolean;
        localTimeoutMs?: number;
        rawResponseBody?: boolean;
    }

    Hierarchy (View Summary, Expand)

    Index

    Properties

    abortSignal?: AbortSignal
    headers?: Record<string, string>

    map of additional request headers

    json?: boolean

    By default, we will:

    • If the body is an object, JSON-encode it and set Content-Type: application/json in the request headers (unless overridden by headers).

    • Set Accept: application/json in the request headers (again, unless overridden by headers).

    • If IHTTPOpts.onlyData is set to true on the FetchHttpApi instance, parse the response as JSON and return the parsed response.

    Setting this to false inhibits all three behaviors, and (if IHTTPOpts.onlyData is set to true) the response is instead parsed as a UTF-8 string. It defaults to true, unless rawResponseBody is set.

    Instead of setting this to false, set rawResponseBody to true.

    keepAlive?: boolean
    localTimeoutMs?: number

    The maximum amount of time to wait before timing out the request. If not specified, there is no timeout.

    rawResponseBody?: boolean

    Setting this to true does two things:

    • Inhibits the automatic addition of Accept: application/json in the request headers.

    • Assuming IHTTPOpts.onlyData is set to true on the FetchHttpApi instance, causes the raw response to be returned as a https://developer.mozilla.org/en-US/docs/Web/API/Blob|Blob instead of parsing it as json.

    MMNEPVFCICPMFPCPTTAAATR