【发布时间】:2018-05-04 05:58:11
【问题描述】:
谁能帮我用 async/await 在 Typescript 中“翻译”这个例子
console.log("start")
var citiesRef = db.collection('cities');
var allCities = citiesRef.get()
.then(snapshot => {
snapshot.forEach(doc => {
console.log(doc.id, '=>', doc.data().name);
});
console.log("end")
})
.catch(err => {
console.log('Error getting documents', err);
});
我测试了一些代码,但我认为我的“forEach”循环有问题。
我在控制台中想要的结果:
start
Key1 => city1
Key2 => city2
end
我在一些测试中得到的结果:
start
end
Key1 => city1
Key2 => city2
提前谢谢
【问题讨论】:
-
snapshot是什么类型?
标签: typescript google-cloud-firestore