After reading YDKJS’c chapter on promises, I’ve decided to do a small project to get some practice using promises. FCC API projects seemed like a perfect choice, so I’ve redone my weather app. You can see the app here.
After finishing it I feel much better about promises in general, but I’m still far away from comfortable. So I’d love if someone could take a look at my JS file and give me some pointers, as to which things could be done better. Thanks in advance!
Ugh I was almost done with the Twitch.TV API project when I found out about promises.
I was so aggravated because I was experiencing the effects of the asynchronous nature of ajax without knowing anything about it.
So naturally I ended up just biting the bullet and nested my ajax requests with the next.
Top marks for using that technique in your project! (I still have yet to )
Yeah, promises can be a little daunting at first, but basics aren’t that hard. And they make your code waaay cleaner and easier to read. Now I can’t even look at my messy code from the previous weather app.
And yeah, I should probably pick up some templating framework or something.
Updated my JS file - added some rejection handlers for promises. They allow you to track what went wrong through the devtools, altho they still don’t give any clue to the user. Will need to work on that.