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
And the Error which im getting is **TypeError: Product.findById is not a function** at exports.getProduct (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\controllers\shop.js:24:11) at Layer.handle [as handle_request] (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\layer.js:95:5) at next (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\route.js:149:13) at Route.dispatch (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\route.js:119:3) at Layer.handle [as handle_request] (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\layer.js:95:5) at D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:284:15 at param (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:365:14) at param (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:376:14) at Function.process_params (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:421:3) at next (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:280:10)
The text was updated successfully, but these errors were encountered:
HIello everyone could u please help me in this issue im facing..
below i smy code:
`exports.getEditProduct = (req, res, next) => {
const editMode = req.query.edit;
if (!editMode) {
return res.redirect('/');
}
const prodId = req.params.productId;
Product.findById(prodId).then(product=> {
if (!product) {
return res.redirect('/');
}
res.render('admin/edit-product', {
pageTitle: 'Edit Product',
path: '/admin/edit-product',
editing: editMode,
product: product
})
}).catch(err=>console.log(err))
}
`
And the Error which im getting is
**TypeError: Product.findById is not a function** at exports.getProduct (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\controllers\shop.js:24:11) at Layer.handle [as handle_request] (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\layer.js:95:5) at next (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\route.js:149:13) at Route.dispatch (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\route.js:119:3) at Layer.handle [as handle_request] (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\layer.js:95:5) at D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:284:15 at param (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:365:14) at param (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:376:14) at Function.process_params (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:421:3) at next (D:\Srikanth\Projects\Udemy\Node\connecting-our-app\node_modules\express\lib\router\index.js:280:10)
The text was updated successfully, but these errors were encountered: