Skip to content

Commit

Permalink
fix: fetchWithTimeout 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jhj2713 committed Aug 13, 2024
1 parent 00aceac commit 8c79c6f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions client/src/utils/fetchWithTimeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 8c79c6f

Please sign in to comment.