My server gets a response from another server with a document from a mongodb database with a body similar to
{
messageDetails: {
body: "hello"
},
customerDetails: {
cstmrFirstName: 'Random',
cstmrLastName: 'Name',
},
}
But the response with the body is being logged to the console as:
{
messageDetails: [Object],
customerDetails: [Object],
}
How can I log the full object to the console with each object's properties?
You can use console.dir. To print with unlimited depth, use {depth: null} option:
console.dir(body, {depth: null});
Try console.log(JSON.stringify(body))
Checkout MDN doc JSON.stringify() for more details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With