Expressjs raw body

Something like this should work:

var express = require('./node_modules/express');
var app = express.createServer();
app.use (function(req, res, next) {
    var data="";
    req.setEncoding('utf8');
    req.on('data', function(chunk) { 
       data += chunk;
    });

    req.on('end', function() {
        req.body = data;
        next();
    });
});

app.post("https://stackoverflow.com/", function(req, res)
{
    console.log(req.body);
});
app.listen(80);

Leave a Comment