const http = require('http');
const querystring = require('querystring');
http.createServer((req,res)=>{
if(req.url.startsWith('/login')){
let pdata = '';
req.on('data',(chunk)=>{
pdata += chunk;
});
req.on('end',()=>{
let obj = querystring.parse(pdata);
res.end(obj.id+' ---- '+obj.name);
})
}
}).listen(3000,()=>{
console.log('server is on!');
})
postman测试时候要选x-www-form-urlencoded,不然会有其他信息出现