post数据怎么获取不到?
var app = require(‘express’)() , server = require(‘http’).createServer(app) , io = require(‘socket.io’).listen(server);
app.post(’/open’,function(req, res){ console.log(req.body); });
5 回复
不是应该 req.body就可以吗?
引入body-parser试试
来自酷炫的 CNodeMD
app.post(’/open’,function(req, res){
var body = "";
req.on('data', function (data) {
body += data;
});
req.on('end', function () {
console.log(body)
});
}