You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm doing deepPopulation of comments in posts, trying to delete comments via ajax delete call.
This error occurs on pages that uses the deep populate.
(node:16600) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CastError: Cast to ObjectId failed for value "null" at path "_id" for model "Post"
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'commentsIds' of undefined
at \routes.js:155:24
at \node_modules\mongoose-deep-populate\lib\plugin.js:70:33
at \node_modules\mongoose\lib\query.js:2559:9
at process._tickCallback (internal/process/next_tick.js:103:7)
Routes.js:155 looks like this
router.get('/post/:id', function(req, res) {
Post.findById(req.params.id).deepPopulate('author commentsIds commentsIds.userId').exec(function(err, post){
res.render('singlepost', {
user: req.user,
title : "post",
post : post,
comments : post.commentsIds, <-- 155
page : 'singlepost'
});
});
});
I know req.body.comment is properly passing through.
The error occurs on the get, like it's trying to reload the page, but it shouldn't as i'm making an ajax post call and event.preventdefault + javascript:void(0) on the tag are properly working.
Any idea? I'm really lost now.
Cheers
The text was updated successfully, but these errors were encountered:
Not sure if same error as #47 but...
I'm doing deepPopulation of comments in posts, trying to delete comments via ajax delete call.
This error occurs on pages that uses the deep populate.
Routes.js:155 looks like this
the delete call looks like this
I know req.body.comment is properly passing through.
The error occurs on the get, like it's trying to reload the page, but it shouldn't as i'm making an ajax post call and event.preventdefault + javascript:void(0) on the tag are properly working.
Any idea? I'm really lost now.
Cheers
The text was updated successfully, but these errors were encountered: