我正在尝试使用 busboy 中间件从 POST 请求中获取正文。
我在主 server.js 中有以下内容
//file upload middleware
var busboy = require('connect-busboy');
app.use(busboy());
我有一个这样设置的路线:
app.post('/create', function(req, res){
req.pipe(req.busboy);
req.busboy.on('finish', function (fieldname, file, filename) {
console.log(req.body);
});
});
但是,如果我向端点发送请求,则会收到以下错误:
_stream_readable.js:501
dest.end();
^
TypeError: Cannot call method 'end' of undefined
at IncomingMessage.onend (_stream_readable.js:501:10)
at IncomingMessage.g (events.js:180:16)
at IncomingMessage.emit (events.js:92:17)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)
我如何阅读这条路线内的正文?