在执行此代码期间,我想创建一个json,其中包含子文档的文档字段(键和值)作为值。
NULL
但是当我在输出白衣中返回该对象时:
function getobjectItemsById(id){
var objectItemsRef = db.collection(collectionName).doc(id).collection(subCollection);
let object_items = [];
return objectItemsRef.get()
.then(snapshot => {
snapshot.forEach(item => {
let object_item = {};
object_item.id = item.id;
object_item.object_item = item.data();
console.log(item.data());
object_items.push(object_item);
})
return object_items;
})
}
我的输出:
[对象对象] [对象对象]
如何获取正确的键和值?
答案 0 :(得分:0)
解决方案:console.log(JSON.stringify(objects))