0👍
✅
Put your parameters in a payload object
setPreparationAreaPrinter ({ commit }, payload){
axios.patch('/preparation_areas/' + payload.preparation_area.id, {
printer: payload.printer.id,
}).then((response) => {...});
}
And reflect it in your click listener:
@click="setPreparationAreaPrinter({printer, preparation_area})"
0👍
You can only pass 1 parameter, so if you need to pass more than 1 use an array. An array qualifies as 1 parameter. Then you can access each parameter in the action via data[0] and data[1]
store.dispatch(‘setSplitData’,[data[0], data [1]])
// in the action:
setSplitData (context, [data1, data2]) { // uses ES6 argument destructuring
//…or with an object:
store.dispatch(‘setSplitData’,{
data1: data[0],
data2: data [1],
})
Source:stackexchange.com