The above is the returned object from firebase and I do this:
JSON.stringify(data) // where data is the returned object
Then I get the error: TypeError: Converting circular structure to JSON
How to properly handle an object response like that from firebase?
This answer paints a picture of what is happening, however, in the case of firebase, how to go about it?
The above is the returned object from firebase and I do this:
JSON.stringify(data) // where data is the returned object
Then I get the error: TypeError: Converting circular structure to JSON
How to properly handle an object response like that from firebase?
This answer paints a picture of what is happening, however, in the case of firebase, how to go about it?
Share Improve this question edited May 23, 2017 at 10:30 CommunityBot 11 silver badge asked Nov 19, 2016 at 12:55 KhoPhiKhoPhi 9,55718 gold badges85 silver badges139 bronze badges2 Answers
Reset to default 4You have to call the val()
method...
JSON.stringify(data.val())
The proper way to handle the error "TypeError: Converting circular struct to JSON" when getting data from Firebase is to enumerate the key/value pairs explicitly and examine them:
Object.keys(data).forEach((key) => {
let value = data[key];
console.log(key + " : " + value);
});
The data you have is almost certainly not the data you think you have.