Reputation: 7099
What should I do in case when I want to call seqEach on two_objects:
Seq()
.seq(function() {
pivotal.getProjects(this);
})
.flatten()
.seqEach(function(data) {
var project_ids = data.project.map(function(x) { return parseInt(x.id); })
console.log('project_ids: '.red + project_ids );
// pivotal.getStories(project.id, { filter: "state:finished" }, this);
})
.seq(function() {
var aggregatedStories = [];
Hash.map(this.args, (function(arg) {
aggregatedStories.push(arg[0]);
}));
res.send(aggregatedStories);
});
Logs:
project_ids: 644511,340755
pivotal.getProjects(this);
returns something like
{"project": { "id": 644511}, { "id": 340755} }
So problem is because data
should be replaced by data.project
but how to do it?
Upvotes: 0
Views: 54
Reputation: 664247
So problem is because
data
should be replaced bydata.project
but how to do it?
Either you add the line data = data.project;
on top of your seqEach
callback, or you inject a mapping function like
.map(function(d) { return d.project; })
into your chain. Or you just change the pivotal.getProjects
method…
Upvotes: 1