Reputation: 9527
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?
Upvotes: 4
Views: 5024
Reputation: 21
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.
Upvotes: 0