Node 中服务端框架如何解析 http 的请求体 body
Issue 欢迎在 Gtihub Issue 中回答此问题: Issue 651
Author 回答者: shfshanyue
在 Node 服务中,通过 http.createServer
接收到的 req 为可读流,对流进行读取数据
const server = http.createServer((req, res) => {
let body = "";
req.on("data", (chunk) => (body += chunk));
req.on("end", () => {
data = body;
res.end(data);
});
});
Author 回答者: Asarua
body-parser?