Set up the get function to get quotes
const getQuotes = (req, res) => {
res.status(200).json({ message: "Get quotes" });
};
Set up the post function to create a quote
const createQuote = (req, res) => {
res.status(200).json({ message: "Create quote" });
};
Set up the update function to update a quote
const updateQuote = (req, res) => {
res.status(200).json({ message: `Update quote, ${req.params.id}` });
};
Set up the delete function to delete a quote
const deleteQuote = (req, res) => {
res.status(200).json({ message: `Delete quote, ${req.params.id}` });
};
Export the functions
module.exports = {
getQuotes,
createQuote,
updateQuote,
deleteQuote,
};
Import the functions into the quoteController.js
file
const {
getQuotes,
createQuote,
updateQuote,
deleteQuote,
} = require("../controllers/quoteController.js");
Replace the quoteRoute.js functions with the ones imported from the controllers
router.get("/", getQuotes);
router.post("/", createQuote);
router.put("/:id", updateQuote);
router.delete("/:id", deleteQuote);
Make sure the router is exported
module.exports = router;
Test the get route with Postman once again
Test the post route with Postman once again
Test the update route with Postman once again
Test the delete route with Postman once again