从数据库中检索数据时出错错误:发送后无法设置标头

时间:2017-01-26 12:55:05

标签: javascript angularjs node.js

var response = {};
var sticky = []

email = req.session.u_email;

var query = "select * from share_item where share_to=?  and status=?";
con.query(query, [email, 1], function(err, results) {
  if (err) {
    console.log(err)
    /*return void res.json({'status':false,"message":"somthing went wrong",'redirect':false});  */
  } else if (results.length > 0) {
    for (i = 0; i < results.length; i++) {
      var query = "select * from sticky where id = ?";
      con.query(query, [results[i].item_id], function(err, result) {
        if (err) {
          console.log(err)
        } else if (result.length > 0) {
          for (j = 0; j < result.length; j++) {
            var note = {
              id: result[j].id,
              des: result[j].description,
            }
            sticky.push(note)
          }
        }
        return void res.json(response)
      })
    }
  }
});

  

收到错误错误:发送后无法设置标头。在快递js我需要数据从表到[i]的结果将是

的解决方案

0 个答案:

没有答案