saves
This commit is contained in:
17
frontend/js/product.js
Normal file
17
frontend/js/product.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// Обработчик для кнопки добавления в корзину
|
||||
function addToCart(productId) {
|
||||
fetch(`/api/cart/add`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ productId }),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
alert('Товар добавлен в корзину');
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Ошибка:', error);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user