【发布时间】:2016-01-23 10:00:47
【问题描述】:
我正在使用 bluebird 来初始化各种类型的数据库连接。
// fileA.js
Promise.all(allConnectionPromises)
.then(function (theModels) {
// then i want to do module.exports here
// console.log here so the expected output
module.exports = theModels
})
这样我就可以从另一个文件中要求上面的那个文件。但是,如果我这样做,我会得到{}。
let A = require('./fileA') // i get {} here
知道怎么做吗?
【问题讨论】:
-
你的参数符合promise.all是prmises数组吗?
-
请检查promise 是否正确执行?
-
@null1941 是的。当我使用 console.log 时,我得到了预期的输出。
-
你能发布更多代码来查看吗?
-
你不能在异步方法中导出