[英]documentSnapshot.data() do not pass to the builder: Flutter
[英]Firestore DocumentSnapshot.data() returns undefined, but in the console it definetly has and it works for other documents
在這個 Firebase Function 我得到兩個 DocumentSnapshots,第一個工作正常,我可以從數據庫中獲取數據(emailNonce),但是第二個 DocumentSnapshot 不知何故沒有數據,object 在那里,我可以在日志中看到它,但在其上調用 .data() 返回未定義:
const addRentalFct = async (data, context) => {
// this works:
const secretsRef = db.collection('user-secrets').doc('Yv3gZU8TeJTixl0njm7kUXXpvhc2');
const secretsSnap = await secretsRef.get();
const dbNonce = secretsSnap.data().emailNonce;
functions.logger.log('got the dbNonce: ', dbNonce);
// this doesn't work, but ir's the same logic as above:
const boxesSecretsRef = db.collection('box-secrets').doc('CB8lNQ8ZUnv4FDT6ZXGW');
const boxSecretsSnap = await boxesSecretsRef.get();
functions.logger.log('got the boxSecretsSnap: ', boxSecretsSnap);
functions.logger.log('got the boxSecretsSnap.data(): ', boxSecretsSnap.data());
const boxPassword = boxSecretsSnap.data().password;
functions.logger.log('the box secret is: ', boxPassword);
...
}
(秘密來自我的開發環境)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.