const product = require(’…/…/db’).product
const route = require(‘express’).Router();
route.get(’/’,(req,res)=>{
product.findAll()
.then((products)=>{
res.status(200).send(products)
})
.catch((err)=>{
res.status(500).send({
error: “colud not retrive products”
})
})
})
route.post(’/’,(req,res)=>{
if(isNaN(req.body.price)){
return res.status(403).send({
error:"price is not valid number "
})
}
product.create({
name:req.body.name,
manufacture:req.body.manufacture,
price:parseFloat(req.body.price)
})
.then((product)=>{
res.status(201).send(product)
})
.catch((err)=>{
res.status(501).send({
error:“error adding product”
})
})
})
exports=module.exports=route
this is my code and i am getting this error
TypeError: Cannot read property ‘findAll’ of undefined
at C:\Users\ARYAN AGRAWAL\Desktop\shoping cart\routes\api\products.js:7:9