kavkax
kavkax

Reputation: 95

Passing value to store getters Vue.js

I'm trying to pass ID as parameter to store getter, but when i console that id I get undefined. Can someone help me with this:

Here is my code:

This is how i call getter:

this.$store.getters['users/list']('users', '123')

This is getter function:

getters: {
    list: (state, getters, rootState, rootGetters, userId) => (key) => {
      console.log(userId)
    }
  }

Upvotes: 0

Views: 344

Answers (1)

Bruno Francisco
Bruno Francisco

Reputation: 4238

You were pretty close:

new Vuex.Store({
  getters: {
    someMethod: (state) => (userid) => {
        console.log(userid);
      }
    };       
  }
})

Upvotes: 1

Related Questions