Cannot read property 'call' of undefined,这个是怎么回事,查了好久,没找到答案
Unhandled rejection TypeError: Cannot read property 'call' of undefined
at D:\nodejs_scott\movieWeb\node_modules\mongoose\lib\query.js:2728:20
Unhandled rejection TypeError: Cannot read property 'call' of undefined
at D:\nodejs_scott\movieWeb\node_modules\mongoose\lib\query.js:2728:20
2017-04-01
坑爹呀,找到问题了。。。
// admin post movie
app.post('/admin/movie/new',function(req,res){
//console.log('========'+ req.body+'\n'+"\n====================="+req.body.movie);
//console.log(req.body.movie.year);
var id = req.body.movie._id;
var movieObj = req.body.movie;
var _movie;
if (id !== 'undefined') {————————这里要加单引号!!!
console.log(1);
Movie.fetch(id,function(err,movie){
if (err) {
console.log(err);
}
console.log(movie);
console.log(movieObj);
_movie = _.extend(movie,movieObj);
console.log(_movie);
_movie.save(function(err,movie){
if (err) {
console.log(err);
}
res.redirect('/movie/'+movie._id);
})
})
}
else{
console.log(2);
_movie = new Movie({
doctor:movieObj.doctor,
country:movieObj.country,
title:movieObj.title,
year:movieObj.year,
poster:movieObj.poster,
language:movieObj.language,
flash:movieObj.flash,
summary:movieObj.summary
});
console.log(_movie);
_movie.save(function(err,movie){
if (err) {
console.log(err);
}
console.log(movie._id);
res.redirect('/movie/'+movie._id);
})
}
})
举报