From the course: JavaScript: Async

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Implementing the all method for executing multiple promises

Implementing the all method for executing multiple promises - JavaScript Tutorial

From the course: JavaScript: Async

Implementing the all method for executing multiple promises

- [Instructor] And so now, moving down to the code that runs when the page is loaded, right now, I have my get, then, catch and finally statements. And I, down here in my finally statement, I'm creating this element called weather div that just creates a reference to a dom element. But I'm going to need to use that in other parts of my code. So, I'm going to cut that and I'm going to move it up here right after my API key, so that's available all throughout my event listener here. And then the next thing I'm going to do is create a variable containing the coded names of the locations that I want to get weather for. So, I'm going to make that a constant, I'm going to call it locations. It's going to be an array. I'm going to break that onto multiple lines for legibility. So I'm going to do Las plus Angeles comma US. So this is the encoding that open weather map expects, and then we'll do San plus Francisco comma US. We'll…

Contents