Skip to content

Instantly share code, notes, and snippets.

@MylesBorins
Created October 26, 2016 20:10
Show Gist options
  • Save MylesBorins/77906db7f0d15b8904ca39094f7c0a01 to your computer and use it in GitHub Desktop.
Save MylesBorins/77906db7f0d15b8904ca39094f7c0a01 to your computer and use it in GitHub Desktop.
Get the body of a request
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