【发布时间】:2020-06-21 03:51:50
【问题描述】:
架构
//架构设置
var campgroundSchema = new mongoose.Schema({
name: String,
image: String,
description: String
})
var campground = mongoose.model("campground", campgroundSchema)
#The error is where coming from here, don't seem to get the campgrounds diplayed
app.get("/campgrounds/:id", function(req, res){
//find the campground with provided ID
campground.findById(req.params.id, function(err, foundCampground){
if(err){
console.log(err)
} else {
//render show template
res.render("show", {campground: foundCampground})
}
})
})
错误信息
** 消息: '在模型“campground”的路径“_id”处,值“5e61150b58e80830240ef790”转换为 ObjectId 失败', 名称:'CastError', 模型:模型{露营地}}**
【问题讨论】:
-
上面列出的Url可以帮到你!!我可以看到你的字符串中有空格
" 5e61150b58e80830240ef790"似乎这可能是问题,所以修剪它并发送它,你应该很高兴..