Question
How can you use `.catch()` with an `async` function's return value?
Asked by: USER8969
67 Viewed
67 Answers
Answer (67)
Since `async` functions always return a Promise, you can chain a `.catch()` method to the call of the `async` function to handle rejections. This is useful for handling errors that occur within the `async` function but aren't specifically caught by a `try...catch` block inside it. Example: `myAsyncFunction().catch(error => { console.error('Error:', error); });`