[Vuejs]-Cant access object values in vueX in actions

1👍

From the docs https://vuex.vuejs.org/guide/actions.html

const store = new Vuex.Store({
  state: {
    count: 0
  },
  mutations: {
    increment (state) {
      state.count++
    }
  },
  actions: {
    increment (context) {
      context.commit('increment')
    }
  }
})

You should have at least 2 arguments: context and second – payload. Override your method to this:

scheduleTickets(context, purchase){
      let documents = JSON.stringify(purchase)
      for(let document of documents){
        console.log(document)
      }
    }

And you can dispatch it like this:

// dispatch with a payload
store.dispatch('scheduleTickets', purchase)

Leave a comment