我已经到了真正的死胡同了。
我有一个内置的应用编程接口在NodeJS快速与顺序化。引起麻烦的方法是:
create(req, res){
agentGame.create({
Agent: req.body.Agent,
Game: req.body.Game,
})
.then(agentGame => res.status(201).send(agentGame))
.catch(error => res.status(400).send(error));
},每当我向它发送任何数据时,它总是正确地显示Agent和Game都为空。
请求正文:{"Agent":3,"Game":1}
这就是模型:
module.exports = function(sequelize, DataTypes) {
return sequelize.define('AgentsGames', {
ID: {
type: DataTypes.INTEGER(11),
allowNull: false,
primaryKey: true,
autoIncrement: true
},
Agent: {
type: DataTypes.INTEGER(11),
allowNull: false
},
Game: {
type: DataTypes.INTEGER(11),
allowNull: false
},
StarterSent: {
type: DataTypes.DATEONLY,
allowNull: true
},
StarterPainted: {
type: DataTypes.DATEONLY,
allowNull: true
},
}, {
tableName: 'AgentsGames'
});
};我找不到任何理由让它一直说body值为Null。我可以手动将值输入到数据库中,如果我将模型设置为允许空值,它将创建具有空值的条目。
有什么帮助吗?
发布于 2019-11-28 22:35:37
这个问题现在已经解决了。
删除了Node_Modules,用npm install重新安装并重新启动了应用程序,它又开始工作了,所以我认为Express.Json中的某个地方的故障是罪魁祸首。
https://stackoverflow.com/questions/59075602
复制相似问题