Currently, I am utilizing Nuxt JS 2.9.2 for constructing a Javascript application. The application incorporates Firebase integration through the Nuxt Fire module, as well as Vuex for managing state and authentication.
The project has been successfully configured, allowing me to create users, log them in, and log them out.
My current objective is to save some data along with the user ID on Firebase. However, I am encountering an error stating $fireDb
is undefined, despite successfully creating the user without any additional information:
function createNewAccount (user) {
const databaseRef = this.$fireDb.ref(`accounts/${user.uid}`)
return databaseRef.set({
displayName: 'Test Display Name', // using part of the email as a username
email: 'My Test Email',
image: 'Some Image' // providing a default profile image for all users
})
}
export const actions = {
/*
* Creating a new user
*/
createUser ({commit}, payload) {
this.$fireAuth.createUserWithEmailAndPassword(payload.email, payload.password).then(function({user}) {
commit('localStorage/setUser', { email: payload.email }, { root: true })
createNewAccount(user)
}).catch(function(error) {
console.log('error registering' + error)
});
}
}
I'm currently investigating why this.$fireDb
remains undefined. Despite following the documentation, it appears that something may be amiss in this aspect?