[Vuejs]-How to implement correctly one getter from auth.js into users.js file getter? (Vue.js)

0👍

To access Vuex getters from another getter you have to pass store.getters to it:

auth.js

[...]

getters: {
  getAuthUser: state => state.user
}

[...]

users.js

[...]

getters: {
  getAllUsersById: (state, getters) => state.userIds.map(id => state.userById[id]).filter(user => user.id != getters.getAuthUser.id)
}

[...]

Since all vuex modules should be menaged by the same Vuex store no import is needed: providing (state, getters) as an argument of getAllUsersById gives the method access to all the getters inside Vuex in addition of the state.

Leave a comment