Last active
August 29, 2015 14:09
-
-
Save aichholzer/94403ce0903bbb4a7d2d to your computer and use it in GitHub Desktop.
Simple pretty printer addition for the console.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The you can call
req.prettify();
orreq.prettify({JSON});
(anywhere) to see the object (req.body
) nicely printed in the console.