Reputation: 6629
This is how am performing commit but data is never passed through
const actions ={
updateBtn({commit}, data){
commit("test", data);
console.log("data is"+data);//data here has a value
}
}
const mutations={
test(state, {data}){
console.log(data) //this is always undefined.
}
}
Where am i going wrong in the mutations
Upvotes: 0
Views: 55
Reputation: 4854
Try using like this without function parameter.
const actions = {
updateBtn({commit}, data){
commit("test", data);
console.log({data}); // data here has a value
}
}
const mutations = {
test(state, data) {
console.log({data});
state.data = data;
}
}
Upvotes: 1