diff --git a/src/api/task/get-task-detail.ts b/src/api/task/get-task-detail.ts index fb5cb2c4..a1caef7c 100644 --- a/src/api/task/get-task-detail.ts +++ b/src/api/task/get-task-detail.ts @@ -19,11 +19,11 @@ export const fetchTaskDetail = async ( } ); - if (!response) return notFound(); + if (response.status === 404) notFound(); return response.json(); } catch (error) { - console.error(error); + throw error; } }; @@ -42,10 +42,8 @@ export const getTaskDetail = async ( `/groups/${groupId}/task-lists/${taskListId}/tasks/${taskId}` ); - if (!response) throw new Error("데이터를 불러오지 못했습니다."); - return response.data; } catch (error) { - console.error(error); + throw error; } }; diff --git a/src/app/[groupId]/tasklist/@task/_components/task-detail.tsx b/src/app/[groupId]/tasklist/@task/_components/task-detail.tsx index 6da8b892..3757528d 100644 --- a/src/app/[groupId]/tasklist/@task/_components/task-detail.tsx +++ b/src/app/[groupId]/tasklist/@task/_components/task-detail.tsx @@ -55,15 +55,13 @@ const TaskDetail = () => { router.push(`${pathName}?list=${taskListId}`); }; - const { data: taskDetailData, isPending } = useGetTaskDetail( - groupId, - taskListId, - taskId - ); + const { + data: taskDetailData, + isPending, + isError, + } = useGetTaskDetail(groupId, taskListId, taskId); - if (taskId) { - if (!taskDetailData) notFound(); - } + if (isError) notFound(); return (