Skip to content

Instantly share code, notes, and snippets.

@aichholzer
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save aichholzer/94403ce0903bbb4a7d2d to your computer and use it in GitHub Desktop.

Select an option

Save aichholzer/94403ce0903bbb4a7d2d to your computer and use it in GitHub Desktop.
Simple pretty printer addition for the console.
var express = require('express'),
app = express();
app.use(function (req, res, next) {
req.prettify = function(json) {
json = json || this.body;
return console.log(JSON.stringify(json, null, 2));
};
next();
});
@aichholzer

Copy link
Copy Markdown
Author

The you can call req.prettify(); or req.prettify({JSON}); (anywhere) to see the object (req.body) nicely printed in the console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment