const http = require('http');
const server = http.createServer(((req, res) => {
if (req.method === "POST") {
console.log("req content-type", req.headers['content-type']);
let postData = "";
//触发请求响应事件
req.on("data", chunk => {
//请求数据
postData += chunk.toString()
});
//触发请求响应完成事件
req.on("end", () => {
//所有请求数据
console.log(postData);
res.end("hello word")
})
}
}));
server.listen(3000);