Created
October 26, 2016 20:10
-
-
Save MylesBorins/77906db7f0d15b8904ca39094f7c0a01 to your computer and use it in GitHub Desktop.
Get the body of a request
This file contains hidden or 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 server = http.createServer(); | |
server.on('request', function(request, response) { | |
var body = []; | |
request.on('data', function(chunk) { | |
body.push(chunk); | |
}).on('end', function() { | |
body = Buffer.concat(body).toString(); | |
// at this point, `body` has the entire request body stored in it as a string | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment