【发布时间】:2017-08-17 21:31:39
【问题描述】:
我是 nodejs 和 promises 的新手。我需要将参数传递给我的承诺链中的回调函数。如下所示:
var first = function(something) {
/* do something */
return something.toString();
}
var second = function(something, item) {
/* need to work with both the args */
}
我的承诺链看起来像
function(item) {
/* the contents come from first callback and the item should be passed as an argument to the second callback */
fs.readFile(somefile).then(first).then(second)
}
我应该将项目作为参数传递,我可以这样做而不破坏我的链条吗?
如果我完全错了,请纠正我。
谢谢
【问题讨论】:
标签: javascript node.js typescript promise