interface FfetchOptions {
    baseUrl?: string;
    body?: BodyInit;
    extra?: RequestInit;
    headers?: HeadersInit;
    json?: unknown;
    method?:
        | string & {}
        | "GET"
        | "POST"
        | "PUT"
        | "DELETE"
        | "PATCH"
        | "HEAD"
        | "OPTIONS"
        | "CONNECT";
    middlewares?: FfetchMiddleware[];
    readBodyOnError?: boolean;
    validateResponse?: false
    | (res: Response) => boolean | Promise<boolean>;
}

Hierarchy (View Summary)

Properties

baseUrl?: string

base url to be prepended to the url

this base url is always treated as a "base path", i.e. the path passed to ffetch() will always be appended to it (unlike the new URL(), which has ambiguous slash semantics)

body?: BodyInit

body to be passed to fetch()

extra?: RequestInit

any additional options to be passed to fetch()

headers?: HeadersInit

headers to be passed to fetch()

json?: unknown

shorthand for sending json body. mutually exclusive with body

method?:
    | string & {}
    | "GET"
    | "POST"
    | "PUT"
    | "DELETE"
    | "PATCH"
    | "HEAD"
    | "OPTIONS"
    | "CONNECT"

http method

'GET'
middlewares?: FfetchMiddleware[]

middlewares for the requests

readBodyOnError?: boolean

whether to read the body of the response on HttpError (i.e. when validateResponse returns false). useful for debugging, but may be undesirable in some cases.

true
validateResponse?: false | (res: Response) => boolean | Promise<boolean>

whether to throw HttpError on non-2xx responses

when a function is provided, it will be called with the response and should return whether the response is valid. if it returns false, the response will be thrown as an HttpError

true