trying to solve async problem in map

This commit is contained in:
Arjun Patel
2019-01-16 00:11:00 -08:00
parent 86dd4c8cdb
commit 4a7078c059
+11 -3
View File
@@ -22,10 +22,18 @@ exports.findByDonorId = (req, res, next) => {
}
})
.then(grants => {
const grants_full_info = grants.map(grant => {});
const grants_full_info = grants.map(grant => {
const causes = grant.getCauses({ raw: true }).then(causes => causes),
regions = grant.getRegions({ raw: true }).then(regions => regions),
organizations = grant
.getOrganizations({ raw: true })
.then(organizations => organizations);
return { grant, causes, regions, organizations };
});
res.status(200).json({
grants,
number_grants: grants.length
grants: grants_full_info,
number_grants: grants_full_info.length
});
})
.catch(error => next(error));