Skip to content

Instantly share code, notes, and snippets.

@aichholzer
Last active August 29, 2015 14:09
Show Gist options
  • Save aichholzer/94403ce0903bbb4a7d2d to your computer and use it in GitHub Desktop.
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
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