Current section: Data fetching 29 exercises
solution

Formal Status

Loading solution

Transcript

00:00 So this is actually a pretty simple refactor. We're going to say let status be either pending, fulfilled, or rejected. And we'll initialize it to pending. And with that then we will set the status to fulfilled. And our error or our status is rejected in this case. And then we'll use that status instead of

00:22 just checking for the existence of certain variables. So status is rejected. Then we'll throw the error. And if the status is pending then we'll throw the ship promise. Otherwise it actually doesn't matter that it's resolved. We'll just continue because that's the only other

00:39 possible explanation. And with that it doesn't actually change our behavior. If we change this to dreadnought. Is that how you spell dreadnought? Oh great, I don't know how to spell dreadnought. Dreadnought, not, I don't know. But if you get dreadnought spelling correct then it will load

00:58 just fine. We just did a simple refactor to get the status of pending, fulfilled, and rejected so that things are a little bit more clear with what's going on. So good job.