I have this code on the Firebase cloud using functions
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. 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 have this code on the Firebase cloud using functions
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. 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
Share Improve this question edited Jul 11, 2017 at 13:44 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges asked Jul 11, 2017 at 8:11 user3906716user3906716 2-
1
well the log is true your array have 2 object, object can not be parsed directly you can use
JSON.stringify(people);
– Oussema Aroua Commented Jul 11, 2017 at 8:47 - I already tried it, did not work. I tried this console.log(JSON.stringify(people)); I am getting: 2017-07-11T09:13:39.483Z I status: "[object Object]" – user3906716 Commented Jul 11, 2017 at 9:10
3 Answers
Reset to default 5I 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. Add if(snap.val().whateverProperty
logic.