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?

If you upgraded to pro, sign in here

  • About
  • Blog
  • Privacy
Looking to email me? You can get me on my first name at allthecode.co