0

我正在尝试调用一个 async/await 函数,该函数接受参数并在 middleware.js 的 helper.js 文件中定义。

助手.js

module.exports.add = async fields => {
One,two.three} = fields;
module.exports.multiple = async fields => {
One,two.three} = fields;

中间件.js

module.exports = async (res,req) => {
const form = new formidable.IncomingForm();
await form.parse(req,(err,fields,file) => {
try{ calling function add }catch{ }
try{ calling function multiple }catch{ } 
});
};

这个语法对吗?有一个更好的方法吗?。如何通过传递参数在我的中间件中调用辅助函数加法和乘法。我正在尝试编写中间件函数,而已经编写了辅助函数。如果我的问题需要澄清,请告诉我。

4

0 回答 0