In the below code, I could see only the finish event emitting and not the field event.
const Busboy = require('busboy');
module.exports.controller = function(app) {
app.post('/api', function(req, res) {
var busboy = new Busboy({ headers: req.headers });
var formdata = {};
busboy.on('field', function (fieldname, val) {
console.log("fieldname : " + fieldname);
console.log("value : " + val);
formdata[fieldname] = val;
});
busboy.on('finish', function() {
res.send(formdata);
});
req.pipe(busboy);
});
};
As response, I receive {}
back in postman. What could be possibly going wrong here?