Instructor: there's one new concept I want to introduce here, and that is I want to account for if we have an error, we want to make sure to display that to the user. If we have an error, we're going to pluck that out of state, we're going to display it right here for the user to see. In order to get an error to throw here, we're going to make our delete item request up here.
We're going to say this is our fake request. That's going to fail for ID three specifically. What we're going to do here is, we will say if the ID is equal to three, the function we're going to pass the set time as is going to be reject, which will reject the promise. Otherwise, we'll resolve it as usual.
As we can see for item one, item two, this is succeeding. If we click on item three, we have yet to handle that rejection. We're going to add for clarity here that we're beginning with null as error in our state, which is why we're not rendering anything quite yet.
If we add a handler here on the promise through the catch, this is what we're going to do if the promise is rejected, we are going to set state error that request failed for item. Since we have the ID right here, I'll use that in the message. We can make sure this is happening as we expect.
There we go. Now, if we click on item three, that we get our error message. Looks like we forget to clear out our loading state, let's go ahead and make sure that in any case that we set loading back to faults.
Now, we'll go ahead, and item two will succeed, item three will fail. We're no longer loading, and we've displayed our error to the user...