Node.js Nodejs async.series未执行所有方法

Node.js Nodejs async.series未执行所有方法,node.js,Node.js,我试图在我的工作中使用“async”,所以我编写了一个示例程序来确保它能正常工作。async.parallel()按预期工作,但async.series()不工作。不知道我错过了什么。有人能看一下这个示例代码并指出问题/错误吗 async.series([task1,task2])只执行“task1” const async = require('async'); var firstThing = function() { setTimeout(function(){console.log(

我试图在我的工作中使用“async”,所以我编写了一个示例程序来确保它能正常工作。async.parallel()按预期工作,但async.series()不工作。不知道我错过了什么。有人能看一下这个示例代码并指出问题/错误吗

async.series([task1,task2])只执行“task1”

const async = require('async');
var firstThing = function() {
  setTimeout(function(){console.log('IN the First thing')}, 1000);
};

var secondThing = function () {
  setTimeout(function(){console.log('IN the second thing')}, 1500); 
};

async.series(
 [
  firstThing, 
  secondThing
 ],
 function (err, result) {
    console.log('blah blah '+result);
});
当我运行这个代码时,我得到

IN the First thing
和出口。为什么不调用第二个任务?我错过了什么


谢谢。

当您完成要串联运行的每个功能时,您必须回拨:

const async = require('async');
var firstThing = function(callback) {
  setTimeout(function(){console.log('IN the First thing')}, 1000);
  callback(/* pass error or callback*/);
};

var secondThing = function (callback) {
  setTimeout(function(){console.log('IN the second thing')}, 1500); 
  callback(/* pass error or callback*/);
};

当您完成要串联运行的每个函数时,必须回拨:

const async = require('async');
var firstThing = function(callback) {
  setTimeout(function(){console.log('IN the First thing')}, 1000);
  callback(/* pass error or callback*/);
};

var secondThing = function (callback) {
  setTimeout(function(){console.log('IN the second thing')}, 1500); 
  callback(/* pass error or callback*/);
};

你错过了回电谢谢我让它工作了你错过了回电谢谢我让它工作了。。