Skip to content

Commit

Permalink
backend sync'd
Browse files Browse the repository at this point in the history
  • Loading branch information
Everything Sats committed Apr 29, 2024
1 parent 66a87b9 commit 03acf1b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion Backend/controllers/foodController.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,15 @@ const addFood = async (req,res) => {
}
}

export {addFood}
// All food list
const listFood = async(req,res) => {
try {
const foods = await foodModel.find({});
res.json({success:true,data:foods})
} catch (error) {
console.log(error);
res.json({success:false,message:"Error"})
}
}

export {addFood, listFood}
3 changes: 2 additions & 1 deletion Backend/routes/foodRoute.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express from "express"
import { addFood } from '../controllers/foodController.js'
import { addFood, listFood } from '../controllers/foodController.js'
import multer from 'multer'

const foodRouter = express.Router()
Expand All @@ -17,6 +17,7 @@ const upload = multer({storage:storage})


foodRouter.post("/add", upload.single("image"), addFood)
foodRouter.get("/list",listFood)



Expand Down

0 comments on commit 03acf1b

Please sign in to comment.