Handle a rejected promise and display error to user using setState()

InstructorErik Aybar

Share this video with your friends

Send Tweet

In this lesson we will account for errors encountered during a failed requests and display a helpful error message to the user. We will add a catch() handler (Promise.prototype.catch) to our request's promise where we will add an error message to component state and set our loading state to false. We'll add an error message to our app that will only display once an error has occurred using conditional rendering.