最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Converting circular structure to JSON Firebase - Stack Overflow

programmeradmin1浏览0评论

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 badges
Add a ment  | 

2 Answers 2

Reset to default 4

You 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.

发布评论

评论列表(0)

  1. 暂无评论