refactor for redundant code
This commit is contained in:
@@ -391,9 +391,9 @@ exports.getProductWithPagination = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
exports.removeProduct = async (req, res) => {
|
||||
exports.removeAnyProduct = async (req, res) => {
|
||||
const { id } = req.params;
|
||||
|
||||
console.log(id);
|
||||
try {
|
||||
const [result] = await db.execute(
|
||||
`DELETE FROM Product WHERE ProductID = ?`,
|
||||
|
||||
@@ -8,6 +8,7 @@ const {
|
||||
getProductById,
|
||||
addProduct,
|
||||
removeProduct,
|
||||
removeAnyProduct,
|
||||
getProductWithPagination,
|
||||
myProduct,
|
||||
updateProduct,
|
||||
@@ -30,7 +31,7 @@ router.post("/addProduct", addProduct);
|
||||
router.get("/getProduct", getAllProducts);
|
||||
|
||||
//Remove product
|
||||
router.delete("/:id", removeProduct);
|
||||
router.delete("/any/:id", removeAnyProduct);
|
||||
//Get products with pagination
|
||||
router.get("/getProductWithPagination", getProductWithPagination);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user