This commit is contained in:
chaosBreaking
2019-10-14 11:01:43 +08:00
parent 792c7d215e
commit 9c55569648

View File

@@ -2,7 +2,7 @@ const formidable = require('formidable');
module.exports = {
async parseForm (req, config) {
if (!req) return null;
if (!req) return {};
const form = new formidable.IncomingForm();
Object.assign(form, config);
form.on('fileBegin', function (name, file) {
@@ -14,7 +14,7 @@ module.exports = {
};
return new Promise((resolve, reject) => {
form.parse(req, function (err, fields, data) {
if (err) return reject(err);
if (err) return reject({});
else return resolve({ fields, data });
});
});