JSON doesn’t accept circular objects – objects which reference themselves.
JSON.stringify() will throw an error if it comes across one of these.
The request (
req) object is circular by nature – Node does that.
In this case, because you just need to log it to the console, you can use the console’s native stringifying and avoid using JSON:
console.log("Request data:"); console.log(req);