I'm trying to export a class with an asynchronous call in the constructor:
my.js
:
module.exports = class My extends Emitter {
constructor () {
super()
this.db = Object.create(db)
this.db.init(cfg)
}
}
db.js
:
module.exports = {
async init (cfg) {
nano = await auth(cfg.user, cfg.pass)
db = nano.use(cfg.db)
},
async get (id) {
...
}
After let my = new My()
, my.db is still empty. How do I wait for init() to be completed?