[Vuejs]-Shopify cart update not working with axios

0👍

Shopify’s Ajax API reference might help shed some light on why this isn’t working for you.

If you need a working snippet of code to get things moving, this is working for me:

function removeCartItem(variantId) {
  let update = {};
  update[variantId] = quantity;

  axios({
    method: 'post',
    url: '/cart/update.js',
    data: { updates: update }
  })
  .then( (response) => {
    // The response should confirm the removal of the item from cart.items
   // Then you probably want to update your state so cart items gets re-rendered
  })
  .catch( (error) => {
    console.error('Error:', error);
  });
}

Leave a comment