Promise.all([...]) returns a new promise that waits for every input promise to fulfill. If any input promise rejects, the returned promise rejects. Use it when several results are needed together. section 30.4 section 30.3
function getAuthorAndArticles(authorId) {
const authorReq = load(`/authors/${authorId}/details`)
const articlesReq = load(`/authors/${authorId}/articles`)
return Promise.all([authorReq, articlesReq]) 1
}
getAuthorAndArticles(37).then( ([author, articles]) => { 2
// author and articles have loaded
});
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":4,\"ch\":65},{\"line\":4,\"ch\":66}],[{\"line\":7,\"ch\":65},{\"line\":7,\"ch\":66}]]"}
!@%STYLE%@!
The author details and articles load through separate requests. Promise.all joins them; the .then callback receives both results for use together. section 30.3
Credit-check page
To render a credit page, combine Promise.all for the credit-availability request with Promise.race for the TransUnion and Equifax score requests. The page needs availability and at least one score. section 30.4

