Skip to content

Commit

Permalink
Update useFetchUsers.js (#194)
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 authored Sep 27, 2023
1 parent ffc3901 commit c7a5cf2
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 c7a5cf2

Please sign in to comment.