mediumJS ES6+#65

Async/await error handling

Prompt

Write an async function getUser(id) that awaits fetchUserData(id) (provided — it rejects for id <= 0) and uses try/catch for error handling. If the fetch fails, return a default object { name: 'Guest' }.

Hints

Solution

Your Code

5 min

Tests

Click Run to test your code