質問

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?

役に立ちましたか?

解決

So problem is because data should be replaced by data.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…

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top