Upon assigning a value retrieved from the firebase collection, I encountered the following error message.
Error getting document: TypeError: Cannot set property 'email' of undefined at eval (Profile.vue?5a88:68)
Here is the code snippet in question.
import firebase from 'firebase';
import fb from "@/firebase";
export default {
name: 'Upload',
data(){
return{
bio: '',
name: '',
email: '',
imageData: null,
picture: 'http://ssl.gstatic.com/accounts/ui/avatar_2x.png',
uploadValue: 0
}
},
created() {
this.setUsers();
},
methods:{
setUsers: () => {
var userRef = fb.collection("users").doc(firebase.auth().currentUser.uid);
userRef.get().then(doc => {
this.email = doc.data().email;
}).catch(function(error) {
console.log("Error getting document:", error);
});
},
}
}
Why am I encountering this particular error and what steps can be taken to rectify it?