【发布时间】:2020-03-16 11:16:39
【问题描述】:
我正在尝试更新用户的送货信息。我在 mongodb 中有我试图用 PATCH/PUT 覆盖的默认数据。现在邮递员无限期地挂起。猫鼬模型有值,我的 else{} 语句输出要提交的 JSON 对象,没有错误,但它永远不会通过。我很感激任何帮助。 邮递员
Could not get any response
app.js
app.put('/api/users/:id', (req, res) => {
User.findByIdAndUpdate({ _id: req.params.id },
{
fullName: req.body.fullName,
address1: req.body.address1,
address2: req.body.address2,
city: req.body.city,
state: req.body.state,
zip: req.body.zip
}, function (err, docs) {
if (err) res.json(err);
else {
// console.log(docs)
}
});
})
型号
const mongoose = require("mongoose");
const shippingSchema = mongoose.Schema({
fullName: { type: String},
address1: { type: String },
address2: { type: String },
city: { type: String },
state: { type: String},
zip: { type: String}
});
module.exports = mongoose.model("Shipping", shippingSchema);
【问题讨论】:
标签: mongodb express mongoose postman