@umbraco-cms/backoffice

    Interface RequestOptions<TResponseStyle, ThrowOnError, Url>

    interface RequestOptions<
        TResponseStyle extends ResponseStyle = "fields",
        ThrowOnError extends boolean = boolean,
        Url extends string = string,
    > {
        auth?: ((auth: Auth) => AuthToken | Promise<AuthToken>) | AuthToken;
        baseUrl?: unknown;
        body?: unknown;
        bodySerializer?: null | BodySerializer;
        cache?: RequestCache;
        credentials?: RequestCredentials;
        fetch?: (request: Request) => Promise<Response>;
        headers?: Record<string, unknown> | HeadersInit;
        integrity?: string;
        keepalive?: boolean;
        method?:
            | "CONNECT"
            | "DELETE"
            | "GET"
            | "HEAD"
            | "OPTIONS"
            | "PATCH"
            | "POST"
            | "PUT"
            | "TRACE";
        mode?: RequestMode;
        next?: undefined;
        parseAs?: | "text"
        | "arrayBuffer"
        | "blob"
        | "bytes"
        | "formData"
        | "json"
        | "auto"
        | "stream";
        path?: Record<string, unknown>;
        priority?: RequestPriority;
        query?: Record<string, unknown>;
        querySerializer?: QuerySerializer | QuerySerializerOptions;
        redirect?: RequestRedirect;
        referrer?: string;
        referrerPolicy?: ReferrerPolicy;
        responseStyle?: ResponseStyle;
        responseTransformer?: (data: unknown) => Promise<unknown>;
        responseValidator?: (data: unknown) => Promise<unknown>;
        security?: readonly Auth[];
        signal?: null | AbortSignal;
        throwOnError?: ThrowOnError;
        url: Url;
        window?: null;
    }

    Type Parameters

    • TResponseStyle extends ResponseStyle = "fields"
    • ThrowOnError extends boolean = boolean
    • Url extends string = string

    Hierarchy

    Index

    Properties

    auth?: ((auth: Auth) => AuthToken | Promise<AuthToken>) | AuthToken

    Auth token or a function returning auth token. The resolved value will be added to the request payload as defined by its security array.

    baseUrl?: unknown

    Base URL for all requests made by this client.

    body?: unknown

    Any body that you want to add to your request.

    https://developer.mozilla.org/docs/Web/API/fetch#body

    bodySerializer?: null | BodySerializer

    A function for serializing request body parameter. By default, JSON.stringify() will be used.

    cache?: RequestCache

    A string indicating how the request will interact with the browser's cache to set request's cache.

    credentials?: RequestCredentials

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

    fetch?: (request: Request) => Promise<Response>

    Fetch API implementation. You can use this option to provide a custom fetch instance.

    globalThis.fetch
    
    headers?: Record<string, unknown> | HeadersInit

    An object containing any HTTP headers that you want to pre-populate your Headers object with.

    See more

    integrity?: string

    A cryptographic hash of the resource to be fetched by request. Sets request's integrity.

    keepalive?: boolean

    A boolean to set request's keepalive.

    method?:
        | "CONNECT"
        | "DELETE"
        | "GET"
        | "HEAD"
        | "OPTIONS"
        | "PATCH"
        | "POST"
        | "PUT"
        | "TRACE"

    The request method.

    See more

    mode?: RequestMode

    A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.

    next?: undefined

    Please don't use the Fetch client for Next.js applications. The next options won't have any effect.

    Install @hey-api/client-next instead.

    parseAs?:
        | "text"
        | "arrayBuffer"
        | "blob"
        | "bytes"
        | "formData"
        | "json"
        | "auto"
        | "stream"

    Return the response data parsed in a specified format. By default, auto will infer the appropriate method from the Content-Type response header. You can override this behavior with any of the Body methods. Select stream if you don't want to parse response data at all.

    'auto'
    
    path?: Record<string, unknown>
    priority?: RequestPriority
    query?: Record<string, unknown>
    querySerializer?: QuerySerializer | QuerySerializerOptions

    A function for serializing request query parameters. By default, arrays will be exploded in form style, objects will be exploded in deepObject style, and reserved characters are percent-encoded.

    This method will have no effect if the native paramsSerializer() Axios API function is used.

    View examples

    redirect?: RequestRedirect

    A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect.

    referrer?: string

    A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.

    referrerPolicy?: ReferrerPolicy

    A referrer policy to set request's referrerPolicy.

    responseStyle?: ResponseStyle

    Should we return only data or multiple fields (data, error, response, etc.)?

    'fields'
    
    responseTransformer?: (data: unknown) => Promise<unknown>

    A function transforming response data before it's returned. This is useful for post-processing data, e.g. converting ISO strings into Date objects.

    responseValidator?: (data: unknown) => Promise<unknown>

    A function validating response data. This is useful if you want to ensure the response conforms to the desired shape, so it can be safely passed to the transformers and returned to the user.

    security?: readonly Auth[]

    Security mechanism(s) to use for the request.

    signal?: null | AbortSignal

    An AbortSignal to set request's signal.

    throwOnError?: ThrowOnError

    Throw an error instead of returning it in the response?

    false
    
    url: Url
    window?: null

    Can only be null. Used to disassociate request from any Window.

    MMNEPVFCICPMFPCPTTAAATR