Skip to content

Commit

Permalink
Update useFetchUsers.js
Browse files Browse the repository at this point in the history
Make error back to undefined when users data exist and make data back to undefined when error exist
  • Loading branch information
zuramoon01 committed Sep 27, 2023
1 parent ffc3901 commit 84d3bee
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export default function useFetchUsers() {
try {
const response = await fetch("https://randomuser.me/api/?results=3");
users = (await response.json()).results;
error = undefined;
} catch (err) {
error = err;
users = undefined;
}
isLoading = false;
}
Expand Down

0 comments on commit 84d3bee

Please sign in to comment.