Weather App - plain JS and Promises

Hey all.
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!

1 Like

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 :sweat:)

I don’t know how you’d go about implementing into your project (I used JQuery so I’m having trouble reading yours haha) but I think maybe looking into “Mustache” may save you some time when constructing new HTML elements with your JavaScript.

Thanks man!

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.

Wow, props to you for going through all the weather app and the twitch.tv api projects. I’ve been so frustrated with the nesting functions in the weather app api can felt there had to be a better way to do it as I was writing this dense, convoluted code. I’m used to C and programming using return values. Javascript was making me feel like I was going insane here.