Skip to content

Instantly share code, notes, and snippets.

@NikhilNanjappa-zz
Last active August 19, 2019 13:21
Show Gist options
  • Save NikhilNanjappa-zz/b6a1733c77a9fba0d375898ace01c1a7 to your computer and use it in GitHub Desktop.
Save NikhilNanjappa-zz/b6a1733c77a9fba0d375898ace01c1a7 to your computer and use it in GitHub Desktop.
const formidable = require('formidable');
module.exports = function (req, res, next) {
const formData = new formidable.IncomingForm();
formData
.parse(req, (err, fields, files) => {
if (err) {
next(err);
} else {
req.body = fields;
req.files = files;
next();
}
})
.on('error', err => {
next(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment