await promise.all .then code example
Example 1: promise.all async await
async function fetchABC() {
const [a, b, c] = await Promise.all([a(), b(), c()]);
}
Example 2: promise all then
var p1 = Promise.resolve(3);
var p2 = 1337;
var p3 = new Promise((resolve, reject) => {
setTimeout(resolve, 100, "foo");
});
Promise.all([p1, p2, p3]).then(values => {
console.log(values); // [3, 1337, "foo"]
});