From c6d9e1c2a5c78d3a42e000014a159d6efd0ca33a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=A9o=20M=C3=A9vollon?= <38255502+matmut7@users.noreply.github.com> Date: Mon, 8 Jan 2024 09:53:30 +0100 Subject: [PATCH] fix: try/catch around fetch (#620) --- src/utils/rest-fetcher.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/utils/rest-fetcher.ts b/src/utils/rest-fetcher.ts index 41cdab4ba..17c4077f3 100644 --- a/src/utils/rest-fetcher.ts +++ b/src/utils/rest-fetcher.ts @@ -1,12 +1,16 @@ import logger from "./logger" const fetcher = async (url: string, params: Record) => { - const response = await fetch(url, params) - if (!response.ok) { - logger.error({ response }, "Error status in response") - return null + try { + const response = await fetch(url, params) + if (!response.ok) { + logger.error({ response }, "Error status in response") + return null + } + return response + } catch (error) { + logger.error("Error attempting to fetch", error) } - return response } export default fetcher