30 Days Of JavaScript

Day 13: Async

Lesson 4: Finally

And just like in try/catch/finally we also have a .finally() option here.

One day 9 I used the example of a loading state being set and unset. Now that I have introduced the idea of code that takes time to run, you can probably understand this a little better.

Let me show you how you would use this for real in code that actually takes time to run.

So you can see here that loading is set to true, then we print out the result of fetching the data from the PokeAPI. Then loading finally sets back to false and we log it out.


Go Pro?

Upgrade to Pro for quizzes, tracked progress and a completion certificate for just $25 🚀

Want more developer tips, tricks and tools?
Then follow me:
FREE Coding Career Quick Start Guide 🚀
Discover the best way to learn to code, how to land a job and valuable resources to help your journey in this free 15 page value packed guide.
Looking to email me? You can get me on my first name at allthecode.co