I am trying to display a value stored in Firestore.
<p class="font-semibold">{{ user_displayName }}</p
export default {
name: "the-navbar",
data() {
return {
name:''
}
},
computed:{
user_displayName() {
const u = firebase.auth().currentUser;
firebase
.firestore()
.collection('Colleges')
.doc(u.uid)
.onSnapshot(function(doc) {
this.name=doc.data().displayName
console.log(this.name)
});
console.log(this.name)
return this.name
},
}
No value or error is being returned and only first console.log
is displaying the data (name).