在promise.all完成后采取行动?

时间:2018-12-17 00:43:22

标签: javascript node.js callback promise async-await

我有一个promise数组,然后在promise之后。我都在做很多异步函数,最终我需要填充一个数组(最终将在数组中放置大约10,000个项目)。我要等到promise.all之后的.then完成,这样我才能运行for循环并将10,000个项目中的100个从排序数组中添加到DB中。如果不能在.promise.all之后的.then之后链接我,该怎么办? 谢谢

1 个答案:

答案 0 :(得分:-1)

您可以使用多个then

轻松地链接诺言
Promise.all([promise1, ...])
    .then(async () => {
        await something();
        await somethingElse();
    })
    .then(async () => {
        // your function to execute after everything
    });
相关问题