diff --git a/index.js b/index.js index 5236b35..1ba13a3 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,7 @@ app.use(bodyParser.json()); // In-memory data store for demonstration let cartData = { cart: { - accessoreis: {}, + accessories: {}, }, }; @@ -46,10 +46,10 @@ app.get("/cart", (req, res) => { }); // READ - Get a specific item in the cart -app.get("/cart/accessoreis/:key", (req, res) => { +app.get("/cart/accessories/:key", (req, res) => { const { key } = req.params; - const item = cartData.cart.accessoreis[key]; + const item = cartData.cart.accessories[key]; if (!item) { return res.status(404).json({ error: `Item with key '${key}' not found` }); @@ -62,7 +62,7 @@ app.get("/cart/accessoreis/:key", (req, res) => { }); // UPDATE - Update a specific item in the cart -app.put("/cart/accessoreis/:key", (req, res) => { +app.put("/cart/accessories/:key", (req, res) => { const { key } = req.params; const { value } = req.body; @@ -70,12 +70,12 @@ app.put("/cart/accessoreis/:key", (req, res) => { return res.status(400).json({ error: "Value is required" }); } - if (!cartData.cart.accessoreis[key]) { + if (!cartData.cart.accessories[key]) { return res.status(404).json({ error: `Item with key '${key}' not found` }); } // Update the item - cartData.cart.accessoreis[key] = value; + cartData.cart.accessories[key] = value; res.json({ message: "Item updated successfully", @@ -84,15 +84,15 @@ app.put("/cart/accessoreis/:key", (req, res) => { }); // DELETE - Remove a specific item from the cart -app.delete("/cart/accessoreis/:key", (req, res) => { +app.delete("/cart/accessories/:key", (req, res) => { const { key } = req.params; - if (!cartData.cart.accessoreis[key]) { + if (!cartData.cart.accessories[key]) { return res.status(404).json({ error: `Item with key '${key}' not found` }); } // Delete the item - delete cartData.cart.accessoreis[key]; + delete cartData.cart.accessories[key]; res.json({ message: "Item deleted successfully",