Skip to content
Advertisement

Passing multiple parameters to Vuex action

I have the following method in my Vue Component

JavaScript

I want to pass the parameters (this.urlWithPage, query) to my Vuex action as follows:

JavaScript

The problem is that the first parameter url is returning a value but the second one query is returning undefined.

My mutation is as follows:

JavaScript

How can I get a value from the second parameter?

Advertisement

Answer

The accepted answer to this also applies to actions, it expects two arguments: context and payload.

In order to pass multiple values you’ll have to send the data across as an object and destructure them:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement