I want to pass a second parameter to a dispatch call:
this.$store.dispatch(
'testAction',
this.employee.employeeId,
departmentId
));
My store Action is the following:
async testAction({ dispatch, commit }, employeeId, departmentId) {
console.log(departmentId);
return 'Employee Tested';
},
When I see console log for departmentId i get "undefined".
Any clue on how to pass multiple parameters?
Thanks
Take a look at the documentation: https://vuex.vuejs.org/guide/actions.html#dispatching-actions
Basically, you can't send multiple parameters. You need to dispatch with a payload
object containing your parameters.
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