From 8c79c6fa50ad06d10cc930b6190c231687f87586 Mon Sep 17 00:00:00 2001 From: jhj2713 Date: Tue, 13 Aug 2024 13:45:07 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20fetchWithTimeout=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/utils/fetchWithTimeout.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/src/utils/fetchWithTimeout.ts b/client/src/utils/fetchWithTimeout.ts index 371107f3..fd9cbd56 100644 --- a/client/src/utils/fetchWithTimeout.ts +++ b/client/src/utils/fetchWithTimeout.ts @@ -3,12 +3,12 @@ export async function fetchWithTimeout(url: string, options: RequestInit = {}, t const id = setTimeout(() => controller.abort(), timeout); options.signal = controller.signal; - try { - const response = await fetch(url, options); - clearTimeout(id); - return response; - } catch (error) { - clearTimeout(id); - throw error; + const response = await fetch(url, options); + clearTimeout(id); + + if (!response.ok) { + throw new Error(response.statusText); } + + return response; }