NODEJS[18]:http模块_获取请求体
·
Yin灏
const http = require("http");
const server = http.createServer((request, response) => {
// 获取请求体
let body = "";
request.on("data", (chunk) => {
body += chunk;
});
request.on("end", () => {
console.log(body);
response.end("Hello HTTP");
});
});
server.listen(9000, () => {
cons.log("服务器已经启动了...");
});