-
-
Save bobwei/6579715c5fb25689199c51e40f89aa42 to your computer and use it in GitHub Desktop.
NodeJS ExpressJS Getting Raw Body on request object
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
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