Open FreshMozzarella opened 1 year ago
async function show(req,res,next) { try { // update one Category const individualCategory = await Category.findById(req.params.id); const categoryProducts = await Product.find({categories : req.params.id}) res.json({category : individualCategory, products : categoryProducts }) } catch (error) { //send error res.status(400).json(error); } };
I agree, definitely implement categories and JWT!
async function show(req,res,next) { try { // update one Category const individualCategory = await Category.findById(req.params.id); const categoryProducts = await Product.find({categories : req.params.id}) res.json({category : individualCategory, products : categoryProducts }) } catch (error) { //send error res.status(400).json(error); } };