Please someone help!!!!!!!!!!!!
This is my Html and app.js file code
<button class="h-6 pl-2" id="plus" data-plus-id="<%= pizza.item._id %>"><i class="fa fa-plus"
aria-hidden="true"></i></button>
This is how get id of pizza:
const plus = document.querySelectorAll("#plus")
function plusQty(inc) {
axios
.post("/plus-qty", inc)
.then(() => {
new Noty({
type: 'success',
timeout: 1000,
text: 'qty inc',
progressBar: false,
killer: true,
}).show();
setTimeout(() => {
window.location.assign("/cart");
}, 2000);
})
.catch((err) => {
console.log(err);
});
}
plus.forEach((btn) => {
btn.addEventListener("click", (e) => {
let inc = btn.getAttribute("data-plus-id");
plusQty(inc)
// console.log(incre)
});
});
> Getting id in controller.js
increase(req, res) {
let cart = req.session.cart;
let item_id = Object.keys(req.body)[0];
let listItem = cart.items[item_id];
// if (cart.totalQty == 0) {
// delete req.session.cart;
// return res.redirect("/cart");
// }
// return res.json({
// totalQty: req.session.cart.totalQty,
// });
}
}
{{“user”:”61efd0ad66dc3aa50486254b”},”cart”:{“items”:{“61dc28da966c28ed6fb9e631”:{“item”:{“_id”:”61dc28da966c28ed6fb9e631″,”pizzaname”:”new peppy paneer”,”image”:”image_1641922230086_new_peppy_paneer.webp”,”price”:199,”size”:”small”,”__v”:0,”des”:”Flavorful trio of juicy paneer, crisp capsicum with spicy red paprika”},”qty”:1}},”totalQty”:1,”totalPrice”:199}}