Untitled
unknown
javascript
2 years ago
560 B
5
Indexable
function getCartItems() {
fetch('/cart.js', {
method: 'GET',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(cart => {
const productIds = cart.items.map(item => item.id);
console.log(productIds);
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
});
}Editor is loading...
Leave a Comment