From a570ac60b2da5e9b1b84d49cb371a8efaec53ddc Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Thu, 28 Nov 2024 10:47:04 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20make=20it=20possible=20to=20spec?= =?UTF-8?q?ify=20fetch=20options=20for=20fetchWithRetry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/@ourworldindata/utils/src/Util.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/@ourworldindata/utils/src/Util.ts b/packages/@ourworldindata/utils/src/Util.ts index 50489833c31..aacbeeb1831 100644 --- a/packages/@ourworldindata/utils/src/Util.ts +++ b/packages/@ourworldindata/utils/src/Util.ts @@ -784,14 +784,18 @@ interface RetryOptions { export async function fetchWithRetry( url: string, - options?: RetryOptions + fetchOptions?: RequestInit, + retryOptions?: RetryOptions ): Promise { const defaultRetryOptions: RetryOptions = { maxRetries: 5, exponentialBackoff: true, initialDelay: 250, } - return retryPromise(() => fetch(url), options ?? defaultRetryOptions) + return retryPromise( + () => fetch(url, fetchOptions), + retryOptions ?? defaultRetryOptions + ) } export async function retryPromise( promiseGetter: () => Promise,