我有一个简单的工作superagent/async瀑布请求,如下所示:
request = require 'superagent'
user = request.agent()
async.waterfall [
(cb)->
user.post('http://localhost:3000/form').send(name: 'Bob').end(cb)
], (err, res)->
console.log err
console.log res
这成功打印了我的完整 http 响应,并且err是undefined.
如果我通过额外的步骤执行完全相同的操作:
request = require 'superagent'
user = request.agent()
async.waterfall [
(cb)->
user.post('http://localhost:3000/form').send(name: 'Bob').end(cb)
(err, res)->
# this is never reached
cb()
], (err, res)->
console.log err # this now prints out the response
console.log res # this is undefined
err现在是回应。res未定义。这是superagent我在这里遇到的问题,还是我只是不正确地使用async's waterfall?