TypeError: Converting circular structure to JSON in nodejs 1


This is because JavaScript structures that include circular references can't be serialized with a"plain" JSON.stringify.

Step 1: Install circular-json in your project by the following code:

 

npm install --save circular-json

Step 2:  Fetch circular-json your file. Write the following code at the beginning of your project:

 

const CircularJSON =require('circular-json');

Step 3: Now put your output inside the following code to display the output:

var str = CircularJSON.stringify(your_output);
 res.send(JSON.parse(str));

 or

var str = CircularJSON.stringify(your_output);
 console.log(JSON.parse(str));