Untitled
unknown
javascript
3 years ago
815 B
18
Indexable
const decreaseQuantity = async (productId, quantity) => {
try {
const response = await axios.post("http://localhost:5174/cart/updatecart", {
productId,
quantity: qty - 1, // use the updated value here
userID: useGetUserID(),
});
if (qty > 1) {
setqty(qty => qty - 1);
}
console.log(response.data);
} catch (err) {
console.error(err.response.data);
}
};
const increaseQuantity = async (productId, quantity) => {
try {
const response = await axios.post("http://localhost:5174/cart/updatecart", {
productId,
quantity: qty + 1, // use the updated value here
userID: useGetUserID(),
});
if (qty >= 1) {
setqty(qty => qty + 1);
}
console.log(response.data);
} catch (err) {
console.error(err.response.data);
}
};Editor is loading...