0

How to retrieve data from a specific getters in vue?

this.$store.getters('client/list'))

TypeError: _this.$store.getters is not a function at eval (Login2.vue?3936:64)

marcelo.delta
  • 2,730
  • 5
  • 36
  • 71

1 Answers1

1

Step 1: Set the getter in the store.

getters: {
     clientList: state => {
          return state.clientList
     }
}

Step 2: Call the getter in your component as computed

computed: {
   clientList () {
          return this.$store.getters.clientList
     }
}

Check your syntax. The getter you posted won't work because you're missing the module-specific syntax.

As an example from the following link: this.$store.getters['ModuleA/getCategory'](this.index)

See more here: Vue.js 2/Vuex - How to call getters from modules that has attribute namespaced:true without mapGetters?

Arc
  • 1,028
  • 6
  • 16
  • Hi @Arc, I was wondering if you could take a second look at my post, to which you responded a few days ago: https://stackoverflow.com/questions/59200408/how-to-retrieve-currentuser-data-with-vue-js-vuex-express-mongodb/59205423#59205423 . I tried adding the ```vuex-persist``` plugin to the store.js file, like you recommended. I am not sure how else to configure this plugin in order to persist. any recommendations? – JS_is_awesome18 Dec 11 '19 at 15:27