From d502d93487750df6ca999174544687d79163fa37 Mon Sep 17 00:00:00 2001 From: muriukialex Date: Sat, 24 Feb 2024 20:34:37 +0300 Subject: [PATCH] update error value on successful request --- hooks/useUserLabsData.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hooks/useUserLabsData.tsx b/hooks/useUserLabsData.tsx index 3b5d009..1581796 100644 --- a/hooks/useUserLabsData.tsx +++ b/hooks/useUserLabsData.tsx @@ -17,16 +17,14 @@ const useUserLabsData = ({ email }: { email?: string | null }) => { try { const response = await getLabs({ email }) const responseData = response.data + setError(null) // update the error value to null setData(responseData) - setIsLoading({ - status: "idle", - }) } catch (error) { const errorResponse = error as ErrorResponse if (errorResponse) { setError(errorResponse) } - + } finally { setIsLoading({ status: "idle", })