Last active
October 18, 2017 12:22
-
-
Save warlock/2741e8182158046922519813c87d1693 to your computer and use it in GitHub Desktop.
Expres.js without body-parser
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.use((req, res, next) => { | |
var data = ""; | |
req.on('data', chunk => { data += chunk }) | |
req.on('end', () => { | |
req.rawBody = data | |
req.jsonBody = JSON.parse(data) | |
next() | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment