I have root state which contains auth data from nuxt/auth..
Inside store/modules/messages/ I have also state and getters etc..
Inside getters I need to get auth data from root state but I dont know how..
I tried adding rootState to index.js from module:
import state from './state'
import rootState from '../../state'
import * as actions from './actions'
import * as mutations from './mutations'
import * as getters from './getters'
export default {
namespaced: true,
state,
rootState,
getters,
mutations,
actions
}
export const avatar = (rootState) => rootState.auth.user.avatar
But this still returns module state..
In a vuex module, a getter gets 4 arguments, namely local state, local getters, root state and root getters.
// messages/getters.js
export function avatar (state, getters, rootState, rootGetters) {
return rootState.auth.user.avatar
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With