[英]Firebase Functions print an object to the console
I have this code on the Firebase cloud using functions我使用函数在 Firebase 云上有这段代码
peopleDataBase.orderByChild("mCalculateFaceSizeWidth")
.endAt(mCalculateFaceSizeWidth())
.limitToLast(1)
.on("child_added", function(snapshot) {
var person = {
"name":snapshot.val().name,
"age":snapshot.val().age,
"id":snapshot.val().id,
"children":snapshot.val().children,
"address":snapshot.val().address,
"image":snapshot.val().image
}
if(key != snapshot.key){
people += person;
key = snapshot.key;
console.log("The entire people list:",people);
}
});
I am trying to print the people object to the console, I have searched for an hour using JSON.stringify and String even $scope and other methods, nothing worked.我正在尝试将人员对象打印到控制台,我已经使用 JSON.stringify 和 String 甚至 $scope 和其他方法搜索了一个小时,但没有任何效果。 In the log on the cloud I am getting在云上的日志中我得到
2017-07-11T07:55:54.593Z I status: The entire people list: [object Object]
Eventually I want to send the object back to the mobile device but I want to make sure I see the data inside.最终我想将对象发送回移动设备,但我想确保我能看到里面的数据。 Ideas?想法?
Thanks Eran谢谢伊兰
I had similar issue.我有类似的问题。 I had to print it without string concatenation:我不得不在没有字符串连接的情况下打印它:
console.log("The entire people list:");
console.log(people);
This works for me:这对我有用:
console.log("The entire people list:", JSON.stringify(people));
just console.log
snap.val()
to see the response.只需console.log
snap.val()
即可查看响应。 Add if(snap.val().whateverProperty
logic.添加if(snap.val().whateverProperty
逻辑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.