I'm trying to implement an authentication system in Nuxt JS 2.9.2, and Firebase 6. I'm using the Nuxt Fire module, and Vuexfire module.
I've successfully setup the system where a user can be created, logged in, and logged out, as well as saving some data to the real time database, however, I'm having some troubles trying to retrieve data from my real-time database.
I'm trying to pull out information from my real-time database based on the user currently logged in, e.g:
store/localStorage.js
import firebase from 'firebase'
import { firebaseAction } from 'vuexfire'
export const state = () => ({
user: null,
account: null
})
export const actions = {
setAccountRef: firebaseAction(({ bindFirebaseRef }, path) => {
return bindFirebaseRef('account', firebase.database().ref(path))
})
}
export const mutations = {
/*
* Set user information
*/
setUser (state, payload) {
state.user = payload
return this.dispatch('setAccountRef', `accounts/${state.user.uid}`)
}
}
Unfortuantly, my setup appears to give me a: [vuex] unknown action type: setAccountRef
error.
For your information, setUser
is ran from another module file:
store/authentication.js
createUser ({commit}, payload) {
this.$fireAuth.createUserWithEmailAndPassword(payload.email, payload.password).then(function({user}) {
commit('localStorage/setUser', { email: payload.email, uid: user.uid }, { root: true })
createNewAccount(user)
$nuxt.$router.push({ path: '/', query: {
alertActive: true,
type: 'info',
message: 'Your account has been successfully created'
}})
}).catch(function(error) {
console.log('error registering' + error)
});
}
What am I missing in terms of the unknown action?