Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VueJS $store.dispatch send multiple parameters

Tags:

vuejs2

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

like image 481
VAAA Avatar asked Jun 21 '18 00:06

VAAA


1 Answers

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.

like image 94
Kim Desrosiers Avatar answered Nov 16 '22 18:11

Kim Desrosiers