2

我是节点新手,使用stormpath 获取自定义数据,我的服务器代码检索组中的帐户以及每个帐户的自定义数据。它应该向客户端发送数据..但是我收到错误..任何帮助都会有所帮助,谢谢。

错误:“发送后无法设置标题。”

app.post('/profile/cards', bodyParser.json(),ExpressStormpath.loginRequired,function(req, res) {
  var href="https://api.stormpath.com/v1/groups/2D48mI3C9uBFJAFW3pp7Kv";
   client.getGroup(href,function(err,group){
      group.getAccounts(function(err,accounts){
        accounts.each(function(account,cb){
          account.getCustomData(function(err,CustomData){
           res.send(CustomData);
        });
          cb();
        },function(err){
          console.log('Finished iterating over accounts');
        });
      });
    });
  });

4

1 回答 1

1

res.send您的代码不起作用,因为您在 Stormpath 中迭代 Groups 并尝试在每次不允许的调用上将网页返回给用户 ( )。

每条路线只能调用res.send()一次。

于 2016-01-11T04:46:13.870 回答