Wiring It All Together
The shape. Set loading and clear the previous error before asking. On success, store the data. On failure, store a message. Either way, stop loading.
That last part is what people forget. A request that fails and leaves loading set to true shows a spinner forever, which is the worst of the four states because it never resolves into anything.
Mark this lesson complete
Signed in, your progress follows you to every device.