Skip to content

Instantly share code, notes, and snippets.

@bobwei
Forked from enreeco/ExpressJS rawBody
Created August 7, 2016 17:37
Show Gist options
  • Save bobwei/6579715c5fb25689199c51e40f89aa42 to your computer and use it in GitHub Desktop.
Save bobwei/6579715c5fb25689199c51e40f89aa42 to your computer and use it in GitHub Desktop.
NodeJS ExpressJS Getting Raw Body on request object
app.configure(function() {
//. . .
app.use(express.bodyParser());
app.use(function(req, res, next) {
var data = '';
req.setEncoding('utf8');
req.on('data', function(chunk) {
data += chunk;
});
req.on('end', function() {
req.rawBody = data;
});
next();
});
//. . .
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment