Untitled
unknown
javascript
a year ago
560 B
2
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