如题~
3 回复
如果是nodejs 自带的http, 大概这样,没验证过, 如是express就可能简单的多:
http.createServer(function(req, res) {
if ('POST' == req.method) {
var body = ''
req.on('data', function(chunk) {
body += chunk
})
req.on('end', function() {
console.log(body)
var j = JSON.parse(body)
res.end('end')
})
}
}).listen(8080);
@beiyio 可能你是get而不是post, 用curl post试下:
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"interfaceid":'1002',"mac": "cat","gameid":"23","uid":"3000"}' http://localhost:1337