Untitled

mail@pastecode.io avatar
unknown
javascript
2 months ago
560 B
0
Indexable
Never
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);
   });
}
Leave a Comment