Home

Issue: 999

Vuex module mutation-type bug

[issue link]

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

This question is available on Nuxt.js community (#c868)