Search code examples
javascriptvue.jsvuejs2vuex

vuex actions - unable to dispatch payload to a consequetive actions from one another


I am trying to call one action from another within the same action.js file. I've linked those up and have achieved this, but the problem is that the first action has to pass a payload to the second.

However, when I do pass the payload:

          store.dispatch('live-chat-queue/test', {
            input: 'test input'
        })

Instead of having access to it in the second action:

    test(payload) {
    console.log('This does not work..', payload)
},

What ends up happening is I get the store returned, instead of the payload:

Console log

I have looked through ought the documentation and could not find the answer why this is returning the store, instead of the payload itself.

Thank you in advance for your help!


Solution

  • As the documentation states, actions receive store object as first argument and payload as second:

    test(context, payload) {
      console.log(payload) // works like expected
    }