When I use store.commit
in middleware it's work, like this
import { getUserFromCookie, getUserFromLocalStorage } from '~/utils/auth'
export default function ({ isServer, store, req }) {
// If nuxt generate, pass this middleware
if (isServer && !req) return
const loggedUser = isServer ? getUserFromCookie(req) : getUserFromLocalStorage()
if (loggedUser) {
store.commit('user/SET_TOKEN', loggedUser)
store.$axios.setToken(loggedUser.token)
}
}
I have use user/SET_TOKEN
mutation-type, the token is set in my user module state
But in my vuex country
module I want commit('select/REMOVE_SELECTED')
in action
throw error
[vuex] unknown local mutation type: select/REMOVE_SELECTED, global type: country/select/REMOVE_SELECTED
So, how to commit mutation-type cross module
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c868">#c868</a>)</em></sub></div>