JavaScript · Exercise 5 of 5 Previous
Intermediate
A user loader with loading, errors and retries
api(id) is a fake fetch (don't change it): id 1 and 2 reply 200 with a user, other ids reply 404, and id 0 fails like a network error.
When Load is clicked: show Loading… in #status and disable the button, then show the user's name, or User not found for a 404, or a message starting with Network error when the request fails. Re-enable the button whatever happens.
What Check tests
- Clicking Load shows
Loading…and disables the button - Id 1 shows
Asha Raoand re-enables the button - Id 7 shows
User not found - Id 0 shows a
Network errormessage and re-enables the button - No uncaught errors
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.