開發wifi模塊配置時,遇到post數據在后端無論用req.body還是用req.params都無法獲得前端post過來的數據,經過baidu、google得到解決辦法
前端post過來的數據是以 Request Payload 格式傳給服務器,
這種格式數據是以流的形式傳遞給后端,此外以流的形式傳遞數據給后端還有post提交文件時的 Form Data格式,
對於流模式傳輸數據,node服務器應監聽req的data事件來接受數據
router.use('/',function (req, res, next) { var str = ""; req.on("data",function (chunk) { str += chunk; }); req.on("end",function () { console.log(str); res.end("ok"); }); });