Skip to content
API/QubeeFetcher

QubeeFetcher

type
src/types/qubee-fetcher.type.ts

The function the fetching APIs call to perform a request. It has the shape of fetch, so the global fetch fits, and so does a wrapper that adds an Authorization header or a client such as ky.

It receives the request’s address, the headers the driver wants on it, and the signal that aborts it. A response whose status is not ok becomes a QubeeFetchError.

import type { QubeeFetcher } from '@qubeejs/react';
import type { QubeeFetcher } from '@qubeejs/react/fetch';

The entries export the same thing: import it from whichever the file already uses.

type QubeeFetcher = (uri: string, init: { … }) => Promise<Response>
const authFetch: QubeeFetcher = (uri, init) =>
fetch(uri, { ...init, headers: { ...init.headers, Authorization: `Bearer ${token()}` } });