我正在尝试将async和request模块一起使用,但我不理解回调函数是如何传递的。我的代码如下:
var fetch = function(file, cb) {
return request(file, cb);
};
async.map(['file1', 'file2', 'file3'], fetch, function(err, resp, body) {
// is this function passed as an argument to _fetch_
// or is it excecuted as a callback at the end of all the request?
// if so how do i pass a callback to the _fetch_ function
if(!err) console.log(body);
});
我正在尝试按顺序获取3个文件并将结果连接在一起。 我被回调函数卡住了,尝试了我能想到的不同组合。 谷歌没有提供太多帮助。