我正在处理合并招摇文件。我想传递数组
[
{ method: '1', path: '/signIn', handler: funation() {return "abcd"},
{ method: '2', path: '/signOut', handler: funation() {return "123"},
]
我根据我的需要得到结果,但它没有传递到module.exports,我在需要这个文件后将它检入另一个文件控制台,我的代码就像
jsonResolve(root, options).then(function (results) {
const result = results.resolved.paths;
// console.log(result);
for (key in result) {
// console.log('keys', key);
const apiRoute = key;
const apiDescription = result[key];
let controller = apiDescription['x-swagger-router-controller'];
for (method in apiDescription) {
// console.log("methods", method);
let newRoute = {};
if (method !== 'x-swagger-router-controller') {
let operationId1 = apiDescription[method].operationId;
newRoute = {
method: method,
path: apiRoute,
handler: controllers[controller][operationId1](),
};
exoprtData.push(newRoute);
}
}
}
return exoprtData;
})
.then((result) => {
console.log(result);
module.exports = result;
})
然后我检查了它的结果。但不传递到 module.exports
我的要求文件代码是这样的,
var ApiRoutes = require("./routes/api");
console.log("ApiRoutes", ApiRoutes);
在这里,我将结果输入控制台
ApiRoutes {}
请帮我解决这个问题。提前致谢