Of course, there are many async questions and answers. But my question is about an async situation in which I need to return something.
I have this in node express:
app.use('/', FalcorServer.dataSourceRoute(function(req, res) {
return new someClass('SOMEHOST', req.query.paths);
}));
Now my problem is this, someClass
is async because of AJAX. (in my example I use setTimeout to make my point).
Something like this:
class someClass {
constructor(redisHost, pathString) {
return setTimeout(function(){
return someModel;
}, 1500);
}
}
module.
exports = someClass;
But I have to deal with this return in my app.use
, how can I do this?