Answer the question
In order to leave comments, you need to log in
How to make a loop with asyncawait, the iterations of which would be executed in parallel?
var exp = [0,1];
Test();
function Test() {
return async(function() {
await([exp.forEach(con)]); // (1)
console.log('finish');
})();
}
function con(num) {
return async(function() {
console.log('start');
return await(opcha);
})();
}
function opcha() {
return new Promise(function(resolve,reject) {
user.find(function(err,doc) {
console.log(doc);
resolve(doc);
});
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question