Skip to content

Commit

Permalink
feat(api): Add fetch option to config
Browse files Browse the repository at this point in the history
Usefull to use custom fetch functions such as https://kit.svelte.dev/docs/loading\#input-fetch
  • Loading branch information
leomp12 committed Jun 21, 2022
1 parent f661c34 commit 9ca0f68
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const api = async <T extends Config>(config: T, retries = 0): Promise<Response &
}, timeout);
let response: Response | undefined;
try {
response = await fetch(url, {
response = await (config.fetch || fetch)(url, {
method,
headers,
signal: abortController.signal,
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Config = {
headers?: Record<string, string>,
timeout?: number,
maxRetries?: number,
fetch?: typeof fetch,
};

type BaseListResultMeta = {
Expand Down

0 comments on commit 9ca0f68

Please sign in to comment.