我在AWS EC2上有mongo和节点一起玩。 Node(w / Express)可以连接到Mongo,所以首先我设置了一个带有两个必填字段“sesh”和“location”的模式。
这是为帖子查询调用的javascript:
app.post('/spotters', function(req,res){
var newSesh = new modelentry(req.body);
newSesh.save(function(err){
if(err)
res.send(err);
res.json(req.body);
});
});
modelentry当然是架构。
我正在尝试使用Postman
发布以下raw / json数据{
sesh: 1,
location: [1,2]
}
但是我总是收到验证失败的消息,如下所示:
{
"message": "hotuser validation failed",
"name": "ValidationError",
"errors": {
"location": {
"message": "Path `location` is required.",
"name": "ValidatorError",
"properties": {
"type": "required",
"message": "Path `{PATH}` is required.",
"path": "location"
},
"kind": "required",
"path": "location"
},
"sesh": {
"message": "Path `sesh` is required.",
"name": "ValidatorError",
"properties": {
"type": "required",
"message": "Path `{PATH}` is required.",
"path": "sesh"
},
"kind": "required",
"path": "sesh"
}
}
}
我查看了很多示例代码,并尝试修改app.post中的函数,但我没有取得任何进展。我真的很感激任何帮助。