I'm trying to access the commit method in a Nuxt store module but outside the default action handler. How can I achieve this?
store/user.js
export const state = () => ({
user: null,
authIsReady: false
})
export const mutations = {
SET_USER(state, user) {
state.user = user
},
SET_AUTH_READY(state, payload) {
state.authIsReady = payload
}
}
const unsub = onAuthStateChanged(auth, (user) => {
// How do I use 'commit' here? This is undefined
commit('SET_AUTH_READY', true)
commit('SET_USER', user)
unsub()
})
Please note that onAuthStateChanged is a function from Firebase.