Skip to content

Commit

Permalink
update error value on successful request
Browse files Browse the repository at this point in the history
  • Loading branch information
muriukialex committed Feb 24, 2024
1 parent 6e16f85 commit d502d93
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions hooks/useUserLabsData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
Expand Down

0 comments on commit d502d93

Please sign in to comment.