hiteshchoudhary / chai-backend

A video series on chai aur code youtube channel
5.06k stars 760 forks source link

getting error while returning response from user register controller #20

Closed Hemantbhatiahb closed 9 months ago

Hemantbhatiahb commented 10 months ago

[TypeError: Converting circular structure to JSON in nodejs]

at - return res .status(201) .json(new ApiResponse(201, createdUser, "User registered Successfully"));

helloshekhawat commented 10 months ago

Hey hemant , this issue is subjective , but this issue means that meaning may be Api response or create user function is refering to itself indirectly, preventing it from being serialized as JSON. you candebug your code to identify if any property in createdUser is referencing the object itself. If you find such a reference, remove it or modify the structure to avoid circularity.

for more details you can read this answer https://stackoverflow.com/questions/27101240/typeerror-converting-circular-structure-to-json-in-nodejs