From the course: JavaScript: Async

Unlock the full course today

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

Preparing the all method for executing multiple promises

Preparing the all method for executing multiple promises - JavaScript Tutorial

From the course: JavaScript: Async

Preparing the all method for executing multiple promises

- [Instructor] In some cases, you need more than one promise to finish before moving onto code that works with the results. While you could write somewhat involved code to do this, promises include an all method that allows you to specify an array containing multiple promises and moving to any chained methods like then and catch only when all promises have finished. The promise.all method returns an array of results from the promises it was passed. For our Explore California page, we're currently including weather only for Los Angeles. But California is a big state. At the very least, we could be including weather for San Francisco as well and maybe even some tourist destinations known for their extreme weather like Yosemite National Park and Mount Whitney. So switching over to our code, we need to rewrite things a little bit to work with a raise, and then we need to actually create our code using promise.all. So our…

Contents