如何将mysql数据从节点正确发送到jsreport服务器

时间:2019-07-24 22:27:56

标签: mysql node.js jsreport

我正在尝试使用nodejs将mysql数据发送到jsreport服务器,但是它出现parser.js错误

我尝试了没有数据,但效果很好

app.get('/admin/print', ensureAuthenticated, function (req, res) {
  if (req.user.role == 3) {
    req.flash('danger', 'this page is only for admins');
    res.redirect('/');
  }
      var sql = "SELECT cus.name, dc.date, dcd.qty, dcd.total_unit, i.item_name FROM delivery_challan dc INNER JOIN customers cus ON cus.id = dc.user_id INNER JOIN delivery_challan_details dcd ON dcd.dc_id = dc.id INNER JOIN inventory i ON i.id = dcd.item_id";
  con.query(sql, function (err, result, fields) {
    if (err) console.log(err);
    var data = {
        template :{'shortid':'rkJTnK2ce'},
        data :{result},
        options :{
            preview : true
        }
    }
    var options = {
        uri: ': http://localhost:5001/api/report',
        method:'POST',
        json:data
    }
    request(options).pipe(res);


  });
});

我遇到此错误

  

C:\ node项目\ kai \ ttlesssons \ kai.git \ node_modules \ mysql \ lib \ protocol \ Parser.js:437             犯错//抛出非MySQL错误             ^       错误:无效的URI“:%20http:// localhost:5001 / api / report”

0 个答案:

没有答案