0
我有一个node.js应用程序使用async一个接一个地调用方法。出于某种原因,当我尝试去瀑布的第二层,我的应用程序将引发以下错误:“对象不是函数”错误?
TypeError: object is not a function
我有下面的代码是CoffeeScript的(如果有人想它,我可以得到的JavaScript):
async.waterfall([
(callback) =>
console.log 'call getSurveyTitle'
@getSurveyTitle (surveyTitle) =>
fileName = 'Results_' + surveyTitle + '_' + dateString + '.csv'
filePath = path.resolve process.env.PWD, 'static', @tempDir, fileName
csv.to(fs.createWriteStream(filePath))
callback(null, null)
,
(callback) =>
@createHeaderRow (headerRow) =>
headerText = _.map headerRow, (row) =>
row.text
csv.write headerText
console.log 'before' #gets here and then throws error
callback(null,headerRow)
,
(headerRow, callback) =>
console.log 'after'
@createRows headerRow, (callback) =>
callback(null,null)
], (err, result) =>
console.log "waterfall done!"
)
对节点和异步我还是比较新的,所以我有一种感觉,我只是忽略了一些明显的东西。任何人都可以看到我在做什么,可能会导致此错误?
真棒谢谢你!那么发生的事情是,第二层是否收到一个空参数,什么时候它根本没有收到任何参数? – 2013-03-05 17:43:18
@AbeMiessler那么,“*应*”取决于你。但是,是的,它收到了一个目前没有预料到的'空'参数。 – 2013-03-05 17:45:14