Sitemap
Estefanía García Gallardo

Estefanía García Gallardo

Just a person who’s in love with computer sciences 💕💕 Developer of Npkill ~ https://npkill.js.org/

Member-only story

JavaScript Promise Methods

Everything you need to know about Promise.all, Promise.allSettled, Promise.race and Promise.any

6 min readJan 2, 2023

--

Press enter or click to view image in full size
Photo by marcos mayer on Unsplash

Introduction

Ever since the introduction of promises in ES2015, which took asynchronism handling to the next level, several new promise methods have appeared, which allow us to perform operations with multiple promises. These methods are the following:

In this guide we’ll cover all of the existing promise methods: how they work, their differences and use cases. I’ve also created Stackblitz projects for each of the examples that will be shown in this guide, where you’ll be able to play around with it and see the output for yourself. You will find the link to the Stackblitz projects at the end of each section.

Promise.all

The Promise.all method receives an iterable (such as an array) of promises, and returns a promise of an array that contains the results of all the resolved input promises.

Let’s take a look at an example:

--

--

Estefanía García Gallardo
Estefanía García Gallardo

Written by Estefanía García Gallardo

Just a person who’s in love with computer sciences 💕💕 Developer of Npkill ~ https://npkill.js.org/