SkyCoder
44
1
Vue

Access root state or $auth from module getters in vuex

Posted 1 week ago by SkyCoder

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..

Please sign in or create an account to participate in this conversation.