Handling Rejections

Rejection
πŸ‘¨β€πŸ’Ό Our API sometimes fails, and we need to handle those failures gracefully. Rejected Promises should be caught so we can return a friendly error state.
🐨 Open
index.ts
and:
  1. Update getUserProfile to handle rejections with .catch()
  2. Return an error result when the Promise rejects
  3. Keep the id parameter flowing through both functions
  4. Export fetchUser and getUserProfile
πŸ’° For the error result, return a { status: 'error', message: string } object. If the value isn't an Error, use 'Unknown error' as the message.

Please set the playground first

Loading "Handling Rejections"
Loading "Handling Rejections"
Login to get access to the exclusive discord channel.
Loading Discord Posts