I'm using Contentful with a MEAN stack. I query the Contentful API and get back a json object.
contentClient.entries(query, function(err, entries){
if (err) throw err;
console.log(entries);
});
I've just been receiving the following error:
[TypeError: Converting circular structure to JSON]
The object is massive (over 3000 lines when I export it from the console to a document). So I can't post it here, but I am wondering if there is a way to find where the circular structure issue is within the object and how I remedy this?
I'm a developer at Contentful and I think I can help with the second part of your question.
As for the first part, greuze's answer is the ideal thing to do if you're in node land. An alternative (that can also be helpful in the browser) is using https://www.npmjs.com/package/safe-json-stringify
As for the second part, a thing the contentful.js library does is resolve links to other entries. The raw JSON contains just an object with metadata for links, but the linked entries come in an attached includes property. The library then goes and resolves those so you don't have to do it yourself.
However, we do allow you to create circular links when linking entries to each other (and you can even link an entry to itself!) and right now we haven't implemented a good way to detect and present those in the CMS (although that's a nice feature idea that I'll propose).
So once you do find that Circular reference, that should be your root issue.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments