我有一个使用异步序列方法的函数。这是因为我需要功能1必须在功能2之前执行,该功能随后必须在功能3之前执行。
async.series([
function1 (function(err, customers) { stufftodo1; }),
function2 (function(err, customers) { stufftodo2; }),
function3 (function(err, customers) { stufftodo3; })
]);
我在一个快速的node.js应用程序中遇到此错误,我不确定如何处理:
(node:22888) UnhandledPromiseRejectionWarning: Error: expected a function
at wrapAsync (/home/ubuntu/concept/node_modules/async/dist/async.js:198:50)
at /home/ubuntu/concept/node_modules/async/dist/async.js:2952:13
at replenish (/home/ubuntu/concept/node_modules/async/dist/async.js:444:21)
at /home/ubuntu/concept/node_modules/async/dist/async.js:449:13
at eachOfLimit$1 (/home/ubuntu/concept/node_modules/async/dist/async.js:475:34)
at awaitable(eachOfLimit$1) (/home/ubuntu/concept/node_modules/async/dist/async.js:208:32)
at eachOfSeries (/home/ubuntu/concept/node_modules/async/dist/async.js:662:16)
at awaitable(eachOfSeries) (/home/ubuntu/concept/node_modules/async/dist/async.js:208:32)
at /home/ubuntu/concept/node_modules/async/dist/async.js:2951:9
at /home/ubuntu/concept/node_modules/async/dist/async.js:216:25
(node:22888) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
答案 0 :(得分:0)
我认为您失去了处理错误和结果的功能。
async.series([function1, function2], function(error, results) {});
您是否使用npm包:异步?