当我尝试发布此
时"_id" : "QQCEyALuMpisEcPb2",
"title" : "hola3",
"listId" : "ZSHvg4gEcKr7y424A",
"boardId" : "fnnkpFjRPhdzMFkrJ",
"archived" : false,
"userId" : "yyJWGn2FZ2AwzHsxT"
使用此架构
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var CardSchema = new Schema({
_id : String,
tittle : String,
listId : String,
boardId : String,
archived :Boolean,
userId : String )};
module.exports = mongoose.model('Card', CardSchema);
我不能,它显示我不能POST /我不知道为什么我试图在数据库中手动插入这个json并且它工作但是当我尝试使用它时它给了我一个错误
router.route('/cards')
.post(function(req, res) {
var card = new Card();
card._id = req.body._id;
card.tittle = req.body.tittle;
card.listId = req.body.listId;
card.boardId = req.body.boardId;
card.archived = req.body.archived;
card.userId = req.body.userId;
card.save(function(err) {
if (err) res.send(err);
res.json({ message: 'Card created!'})
});
});
我使用REST控制台试试这个。
答案 0 :(得分:1)
我解决了自己,我正在以糟糕的方式运行应用程序,代码没问题,ty