I know this type of question already asked here . I have also looked at following question . But it didn't help , those question deals with when parameter is the mongoose object id . But in my case batch_id
is not mongoose object id .
What's Mongoose error Cast to ObjectId failed for value XXX at path “_id”?
Express/Mongoose Router: 'Cast to ObjectId failed for value “undefined” at path “_id”'
Here is what i did .
router.route("/view_by_batch/?:batchid").get(function(req,res){
if(req.session.user){
barcodeEntry.find({batch_id:req.params.batchid},function(err, data) {
if (err) return console.error(err);
res.render('view_by_batch',{ data: data,batch_no:req.params.batchid});
});
}else {
res.render('index',{auth:false});
}
});
I am getting the following error in console
message: 'Cast to number failed for value "style.css" at path "batch_id"',
name: 'CastError',
kind: 'number',
value: 'style.css',
path: 'batch_id' }
Even I removed the link of style.css
file but , it didn't help .