我使用ReactJS,nodejs和mysql开发了一个发票,它具有动态表,如您在此链接中看到的发票组件:https://codeshare.io/5zqLeN
我的路由器是:
exports.ajouterfact = function(req, res) {
console.log("req", req.body);
var today = new Date();
var factures = {
"Nfact": req.body.Nfact,
"Nom": req.body.Nom,
"Datefact": req.body.Datefact,
"Note": req.body.Note,
"Nomp": req.body.Nomp,
"QuantiteF": req.body.QuantiteF,
}
connection.query('INSERT INTO factures SET ?', factures, function(error, results, fields) {
if (error) {
console.log("error ocurred", error);
res.send({
"code": 400,
"failed": "error ocurred"
})
}
else {
// console.log('The solution is: ', results);
res.send({
"code": 200,
"success": "facture registered sucessfully"
});
}
})
};
我的发票是:
提交时,将通过以下方式将其添加到数据库中:
req { Nfact: '15',
Nom: 'Imen',
Datefact: '2018-09-04T09:47:32.925Z',
Note: 'Test',
QuantiteF: '' }
乘积(Nomp)的名词为null,数量为”。
但是当我在Postman上运行后端时,效果很好。
我该如何解决?