I am trying to run async.parallel
inside an ES6 class like this:
public getConsole(req: Request, res: Response) {
async.parallel({
count: this.getDocumentCount,
collectionSize: this.getCollectionMb
},
(err, results) => {
res.json(results);
})
}
but this is undefined. I can't do . . . this.getDocumentCount.bind(this)
because this is still undefined in that context. I also can't do
async.parallel({
count: this.getDocumentCount,
collectionSize: this.getCollectionMb
}.bind(this),
(err, results) => {
res.json(results);
})
}
because typescript complains.