<button class="btn" @click="removeFromTheCart(index,item.price)">
Remove
</button>
I'm passing two parameters to my action removeFromTheCart.
removeFromTheCart({ commit }, payload) {
console.log("rooooooohhhhhoooow",payload)
When I console log my payload inside the vuex store it only outputs the index. My second parameter wasn't in the output.
How do I get two parameter values through an action?
You can send an object as your payload, like this :
<button class="btn" @click="removeFromTheCart({ index, price: item.price })">Remove</button>
And fetch the data in your store :
removeFromTheCart({ commit }, { index, price }) {
console.log('index', index, 'price', price);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With