[Vuejs]-I am trying to get data form my vuex store but it is giving an error

0👍

I think getter allUsers has no difference with state.users, you could set its default value to [].

const selectedUser = this.$store.getters["user/allUsers"].find(
     (user) => {
          return user.username === this.currentUsername;
     }); // here this.currentUsername is undefined in vuex? so
    // Uncaught (in promise) TypeError: Cannot read property 'roles' of undefined

you can use vue devtools to inspect its data flow to check the issue

Leave a comment