Siema mam problem poniewaz pokazuje mi blad ze
TypeError: products.find is not a function
router.get('/product/:id', function (req, res, next) {
products.findById(req.params.id).exec(function (err, products) {
if (err) {
//return res.render("error", { title: "Error" });
res.status(404).json({
message: 'File Not Found 404'
})
} else {
products.find({ _id: req.params.id }, function(err, products){
if (err) {
console.log('error');
} else {
console.log(product);
res.json(product);
}
})
}
})
});
Cały kod:
http://wklej.org/id/3208866/
Powie mi ktoś co zrobiłem źle, ewentualnie jak to poprawić??