首页 > 解决方案 > TypeError: _babel_runtime_corejs2_core_js_promise__WEBPACK_IMPORTED_MODULE_17___default.a.allSettled 不是函数

问题描述

我正在尝试在我的反应项目中使用 Promise.allSettled,如下所示。我想解决所有承诺,即使其中一个失败。

出现以下错误:

TypeError: _babel_runtime_corejs2_core_js_promise__WEBPACK_IMPORTED_MODULE_17___default.a.allSettled is not a function

我的代码:

const promises = [
  getConvWithTextAndMatchWordsForCardForStoryOrOpptyP(bigNameCallOptions),
  getHeuristicScoreDetailsForCardAndStory(heuristicsPayload),
];
if (params.cardId > 0) {
  promises.push(getPlaybookCardDetails(params.cardId));
}
Promise.allSettled(promises).then( rest of the code... )

我的依赖项如下

"node": v14.17.4,
"webpack": "^4.20.2",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/polyfill": "^7.0.0"

不知道为什么我会遇到这个问题。先感谢您。

标签: node.jswebpack

解决方案


推荐阅读