I have a route:
router.get('/:bar', (req, res) => {
Style.distinct('id', {'foo': req.params.bar })
.then(ids =>
// [00001, 00002, 00003, 00004, ... 99999]]
// get Style
// get Config
// etc..
});
});
In distinct then
function, I would like to replace id 00001
with it's object & configuration (to do it, I have to query the Schema):
Style.find({'id', id})
Config.find({'id', id})
I'm stuck in callback hell. I am trying to achieve the following output:
{
00001 : {
style: {}
config: {}
},
00002 : {
style: {}
config: {}
},
00003 : {
style: {}
config: {}
}
}
However, I am unsure how to return the response of two concurrent API calls in an object, and return an array of objects when complete.