如何解决“ TypeError:Promise.allSettled不是函数”?

时间:2019-09-05 07:08:23

标签: javascript node.js promise

我遇到TypeError:Promise.allSettled在节点js中运行promise.allSettled函数时不是函数。请让我知道解决方案

const promise1 = Promise.resolve(3);
const promise2 = new Promise((resolve, reject) => setTimeout(reject, 100, 'foo'));
const promises = [promise1, promise2];

Promise.allSettled(promises).
    then((results) => results.forEach((result) => console.log(result.status)));

0 个答案:

没有答案