From c71ab92a6f89c794080f13ba8eb9742c5f564552 Mon Sep 17 00:00:00 2001 From: Jeremy Tadman Date: Wed, 16 Feb 2022 11:41:33 +1100 Subject: [PATCH] use provided fetch implementation from fetch/mutate options --- src/client.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client.js b/src/client.js index ba20b3b..0f85f7e 100644 --- a/src/client.js +++ b/src/client.js @@ -156,6 +156,7 @@ export class ApiClient { staleTime = this.config.staleTime, headers, hydrate, + fetch, } = config const query = this.getQuery(queryArg) @@ -190,7 +191,7 @@ export class ApiClient { isFetching: true, }) - const request = this.request(query.url, { headers }) + const request = this.request(query.url, { headers, fetch }) query.promise = (async () => { query.cache = await request @@ -366,8 +367,10 @@ export class ApiClient { abort = () => controller.abort() } - const promise = this.config - .fetch(uri, options) + const fetchFn = options.fetch || this.config.fetch; + delete options.fetch; + + const promise = fetchFn(uri, options) .then(res => { return res.status === 204 ? {} : res.json() })