After tackling the issue, I managed to resolve it in the following way:
login() {
fb.auth.signInWithEmailAndPassword(this.loginForm.email, this.loginForm.password).then( function (user) {
this.$store.commit('setCurrentUser', user)
this.$store.dispatch('fetchUserProfile')
this.$router.push('/navigation')
}).catch(err => {
this.errorMsg = err.message
})
},
The original code snippet was sourced from the vuegram project by Savvy app.
Initially, an error was thrown stating that 'Function CollectionReference.doc() requires its first argument to be of type non-empty string, but it was: undefined'.
To troubleshoot, I referred to a suggestion on stackoverflow advising to change the javascript function() to an arrow function. This adjustment did not entirely fix the issue as it resulted in undefined user info from firebase. To address this, I included additional code based on my previous experiences.
login() {
fb.auth.signInWithEmailAndPassword(this.loginForm.email, this.loginForm.password).then(() => {
var user = fb.auth.currentUser;
console.log("User id: ", user.uid)
this.$store.commit('setCurrentUser', user)
this.$store.dispatch('fetchUserProfile')
this.$router.push('/navigation')
}).catch(err => {
this.errorMsg = err.message
})
},
As a result, the browser console now displays the successfully fetched user data.
https://i.sstatic.net/XAyDR.png