【发布时间】:2020-04-02 19:20:30
【问题描述】:
我正在尝试在我的 SignUp 类中创建用户名列表,以仅允许创建唯一的显示名。但是,当尝试如下查看对象的 displayName 时,在控制台中,当初始对象被映射时,我可以看到 displayName,但尝试将其存储为变量会给我的值未定义。
function nameCheck(){
let userList = [];
db.collection("userNames").get().then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
// doc.data() is never undefined for query doc snapshots
console.log(doc.id, " => ", doc.data()) //I can see the parameter displayName here with //proper value
console.log(doc.displayName) //here it is being logged as undefined
});
console.log(userList); //I can see the array has the right amount of objects, but they are all //undefined
});
我确信这很简单,但我根本无法让它工作。
【问题讨论】:
标签: javascript reactjs google-cloud-firestore