modify MediaApi to support custom fetch implementation, defaults to native fetch (#158)

* modify MediaApi to support custom fetch implementation, defaults to native fetch

added an optional `fetcher` parameter to allow usage of a custom fetch function in both `upload` and `fetcher` methods. Defaults to the standard `fetch` if none is provided.

* fix tests and improve api fetcher types
This commit is contained in:
dswbx
2025-04-22 15:44:55 +02:00
committed by GitHub
parent 5763a6e150
commit a1be1b4bf4
4 changed files with 27 additions and 10 deletions
+6 -1
View File
@@ -8,6 +8,11 @@ import { omitKeys } from "core/utils";
export type TApiUser = SafeUser;
export type ApiFetcher = (
input: RequestInfo | URL,
init?: RequestInit,
) => Response | Promise<Response>;
declare global {
interface Window {
__BKND__: {
@@ -21,7 +26,7 @@ export type ApiOptions = {
headers?: Headers;
key?: string;
localStorage?: boolean;
fetcher?: typeof fetch;
fetcher?: ApiFetcher;
verbose?: boolean;
verified?: boolean;
} & (