Answers for "payload to action vuex"

0

payload to action vuex

In simple terms you need to build your payload into a key array

payload = {'key1': 'value1', 'key2': 'value2'}
Then send the payload directly to the action

this.$store.dispatch('yourAction', payload)
No change in your action

yourAction: ({commit}, payload) => {
  commit('YOUR_MUTATION',  payload )
},
In your mutation call the values with the key

'YOUR_MUTATION' (state,  payload ){
  state.state1 = payload.key1
  state.state2 =  payload.key2
},
Posted by: Guest on February-15-2022

Code answers related to "payload to action vuex"

Browse Popular Code Answers by Language