Home > Blockchain >  Pretty print request object in Node.JS?
Pretty print request object in Node.JS?

Time:04-20

Is there a way to pretty print a request object in Node? The default console.log is not very informative.

CodePudding user response:

I don't know that the 'request' object you mean. For most of js object, you can try:

console.dir(req, {depth: null, colors: true})

CodePudding user response:

Your question is unclear. A request object does not mean anything without the context/technology from which it results. I assume you are working with some Web/Rest framework. As for the "pretty" I assume you want to trim informations out of it to only display what you want in the terminal? In that case take a look at a logger middleware you could add such as Morgan.

  • Related