【发布时间】:2019-02-04 01:37:41
【问题描述】:
如果 Promise.all 解决后满足某些条件,我想从函数返回。但是return语句似乎没有效果,函数继续执行。
这是我的代码:
function somefunc() {
Promise.all([match2, match3, match4, match5]).then(results => {
console.log(results);
if(results.indexOf(false) > -1) {
return; // has no effect. somefunc() does NOT return.
}
else {
// ............
};
}).catch(err => {
console.log(err);
});
// this continues to get executed even after the return staement
}
【问题讨论】:
标签: javascript node.js promise