How to use vuex namespaced getters with arguments?

Canor picture Canor · Jan 23, 2018 · Viewed 8.7k times · Source

I have issue when Im using vuex.

I have getters in namespaced module and I cant figurę out how to get the data with Ii when Im passing some arguments.

this.$store.getters.feeders.getFeedersById(id)

And in maper.

...mapGetters({
   feeders: ['feeders/getFeedersById'](this.id)

Getting error like this getter is not a function. What else shoudl I do?

Answer

Canor picture Canor · May 22, 2018
feedersById(state) {
    return rowId => {
        if (state.feedersArray.hasOwnProperty(rowId)) {
            return state.feedersArray[rowId].map(id => state.feeders[id]);
        }

    }
},

feedersId() {
  if (this.rowData) {
   return this.$store.getters['feeders/feedersById'](this.rowData.ac_id);
  }
}

Okey I had some mistake there and now it works properly. Thanks!! :)