Vuex: Passing multiple parameters to an action

Vuex mutations take up to two arguments: state and payload. The current state of the store is passed in by Vuex automatically as the first argument and the second argument holds any parameters you pass in.

The easiest way to pass a number of parameters is to destruct them:

mutations: {
  authenticate(state, { token, expiration }) {
    localStorage.setItem('token', token);
    localStorage.setItem('expiration', expiration);
  }
}

Which allows you to commit your changes in actions in an identical manner:

store.commit('authenticate', {
  token,
  expiration,
});