【发布时间】:2019-02-28 11:34:12
【问题描述】:
当我尝试从 firestore 获取值并将其放入变量时结果未定义,但在控制台中有效。
我的代码:
this.db.collection('Users').doc(uid).get()
.then((docSnapshot) => {
if (docSnapshot.exists) {
this.db.collection('Users').doc(uid)
.onSnapshot((doc) => {
console.log(doc.data()); //working
perfil = doc.data(); //not working
});
}
});
console.log(perfil); //not working. Display undefined
【问题讨论】:
标签: javascript firebase google-cloud-firestore