question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Converting circular structure to JSON at JSON.stringify (<anonymous>)

See original GitHub issue

Here is my code:

const url = "https://subratasarkar.com/process_login.php";
const data = { action: "json_data" };
const response = await axios.post(url, data);

const jsonText = JSON.stringify(response);
const objResponse = JSON.parse(jsonText);
console.log(objResponse);

I am outputting the following simple JSON from my PHP web service: {"id":"amzn1.account.AGABBMWJLHV7ESFWIS3F7KWVGO6Q","name":"Jenny Morrison","email":"aws.jennym@gmail.com"}

What I am doing wrong?! PS: The above JSON output is available at https://subratasarkar.com/process_login.php?action=json_data.

This is a fake user created for testing purpose only hence I am sharing the actual detail.

I actually posted it first at https://github.com/axios/axios/issues/836 then realized the thread was closed. Hence opening a new issue.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonsaaymancommented, May 31, 2019

@emfluenceindia I will have a look and try to replicate this one for you tonight, can you let us know if the solution of #2180 worked for you on the GET request?

0reactions
jane00commented, Mar 4, 2020

response can NOT , stringify (response.data) instead

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is TypeError: Converting circular structure to JSON?
TypeError : Converting circular structure to JSON occurs when you try to reference your variable name within the JSON object.
Read more >
How can I print a circular structure in a JSON-like format?
In Node.js, you can use util.inspect(object). It automatically replaces circular links with "[Circular]". Albeit being built-in (no ...
Read more >
Converting Circular Structure to JSON - Career Karma
A circular structure is an object that references itself. In the example below, we are referencing the object (obj) as a value for...
Read more >
TypeError: Converting circular structure to JSON in JS
The "Converting circular structure to JSON" error occurs when we pass an object that contains circular references to the JSON.stringify() method.
Read more >
TypeError: Converting circular structure to JSON - YouTube
: JSON. stringify (value); TypeError : Converting circular structure to JSON.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found