Passing multiple parameters to vuex mutation via action in Vue.js

Vuex mutations expect two arguments ie. state and payload . The first argument is the

current state of the store and it is passed by vuex itself. Second argument is any parameters that you need

to pass. The second argument is optional.

mutations: {

authenticate(state, { token, expiration }) {

localStorage.setItem('token', token)

localStorage.setItem('expiration', expiration)

}

}

In the actions:

commit('authenticate', {

token,

expiration

})

You can also send the payload directly to action after storing payload as key array.