由于異步,我正在嘗試從 forEach 切換到 Promise。
我試過了:
const ref1 = await firestore.collection("collection").get();
await Promise.all(ref1.map(async (doc) => {
// ...
}));
但它拋出:TypeError: ref1.map is not a function。
(我想回圈瀏覽 ref1 檔案)
完整代碼:
uj5u.com熱心網友回復:
ref1是一個QuerySnapshot沒有map()功能的。它有一個docs屬性是一個陣列QueryDocumentSnapshot。嘗試:
const ref1 = await firestore.collection("collection").get();
const data = ref1.docs.map((doc) => {
return { id: doc.id, ...doc.data() }
}));
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/522312.html
標籤:Google Cloud Collective 节点.js火力基地谷歌云火库
上一篇:在宣告變數之前使用的python中的_是什么?[復制]
下一篇:運行任何反應專案都會出現以下錯誤
