Answer the question
In order to leave comments, you need to log in
How to call getter in another vuex module?
I am writing an application using vue, vuex and all sorts of stray. There are store/user.js and store/accesses.js modules. User has a getter that returns the id of the current user. In accesses there is a getter that returns a certain array of data. But I need to filter the data to return only those related to this user. I can't call the getter directly, because it's not the right module. And I have no idea what to do.
export default {
state: {
user: {
isAuthenticated: false,
uid: null
}
},
mutations: { /* ... */ },
getters: {
isUserAuthenticated: state => state.user.isAuthenticated,
userUid: state => state.user.uid
}
}
state: {
accesses: [
{
id: 'fsfwefsfadsfas',
user: '6BlfZKVMUsWTd1W5KAHIZ3XLmmA2',
},
{
id: 'fsfwefsfaeqwdsfas',
user: '6BlfZKVMUsWTd1W5KAHIZ3XLmmA2',
}
]
},
mutations: { /* ... */ },
getters: {
getAccesses: state => state.accesses
},
actions: { /* ... */ }
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question