我在数组中有六个promises,我想顺序遍历它们,因为最后两个是数据库查询,其中一个依赖于另一个,但前四个并不重要。无论如何,我试图运行#include "iostream"
using namespace std;
void main()
{
enteragain:
cout << "-----Enter a Number----\n";
int number;
char choice;
cin >> number;
if (number> 999 && number <10000 ) {
cout << "\nNumber is four digit\n";
cout << "Would You like enter another number? press y for yes or n for no = ";
cin >> choice;
if (choice == 'y')
{
goto enteragain;
}
if (choice == 'n')
{
goto nowexit;
}
}
else
{
cout << "Not a four digit number \n";
goto enteragain;
}
nowexit:
system("pause");
}
并附加Promise.each
块:
catch
但我还是得到了:
var promises = [promise1, promise2, promise3, promise4, promise5, promise6];
Promise.each(promises, (value, index, length) => {
return next();
}).catch((e) => {
console.log(e);
return next();
});
或者,前四个promises可以异步运行,所以我想使用嵌套在Promise.all中的Promise.each。我还在测试它,它可能会有效,但为什么这会在一个Unhandled rejection Error: Cannot do X in Y
上运行?如果我只有一个Promise.each
?
Promise.each