我想使用pivotal-node
node.js 的模块返回完成的关键故事数组。
app.get('/delivered_stories', function(request, response) {
pivotal.useToken("my_token");
pivotal.getProjects(function (err, data) {
var project_ids = data.project.map(function(x) { return parseInt(x.id); });
console.log('Retrived project ids: '.blue + project_ids);
project_ids.forEach(function(id) {
pivotal.getStories(id, { filter: "state:finished" }, function(err, story) {
response.send(story);
});
});
response.end(); // End the JSON array and response.
});
});
我做错了什么?以及如何解决?我收到一个错误:
http.js:708
throw new Error('Can\'t set headers after they are sent.');
^
Error: Can't set headers after they are sent.
完整代码:https ://gist.github.com/regedarek/30b2f35e92a7f98f4e20