Promises . .
, :
promiseArray.push(got(url + param));
got() , , .
Promise.all() promises , . "" - . async promises. , async, async.
, :
let promiseArray = [];
for (param of params) {
promiseArray.push(got(url + param));
}
got() , async . got() , promiseArray. , async .
// Inspect the promises
for (promise of promiseArray) {
console.log(JSON.stringify(promise));
// Output: promise: {"_pending":true,"_canceled":false,"_promise":{}}
}
promises, , - , , async .
Promise.all(promiseArray).then((results) => {
// Operate on results - works just fine
}).catch((e) => {
// Error handling logic
});
, Promise.all(), promises, , , .