Javascript Firebase reactjs未返回文档
这段代码应该将文档作为对象返回,但它返回的是奇怪的东西Javascript Firebase reactjs未返回文档,javascript,reactjs,firebase,google-cloud-firestore,Javascript,Reactjs,Firebase,Google Cloud Firestore,这段代码应该将文档作为对象返回,但它返回的是奇怪的东西 您在中获得的快照方法是查询快照。要检查其内容,应使用为其定义的方法和属性 例如,上的文档包含以下示例: 如果我们将此应用于您的代码,它将变成: db.collection("cities").where("capital", "==", true) .get() .then(function(querySnapshot) { querySnapshot.forEach(function(doc) {
您在
中获得的快照
方法是查询快照
。要检查其内容,应使用为其定义的方法和属性
例如,上的文档包含以下示例:
如果我们将此应用于您的代码,它将变成:
db.collection("cities").where("capital", "==", true)
.get()
.then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
// doc.data() is never undefined for query doc snapshots
console.log(doc.id, " => ", doc.data());
});
})
.catch(function(error) {
console.log("Error getting documents: ", error);
})
db.collection("cities").where("capital", "==", true)
.get()
.then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
// doc.data() is never undefined for query doc snapshots
console.log(doc.id, " => ", doc.data());
});
})
.catch(function(error) {
console.log("Error getting documents: ", error);
})
var db=firebase.firestore()
db.collection('sp')
.get()
.then(snapshot=>{
snapshot.forEach(function(doc) {
// doc.data() is never undefined for query doc snapshots
console.log(doc.id, " => ", doc.data());
});
})
.catch(err=>console.log(err))