I'm trying to return an array and a map from my NodeJS request.
let returnData = {
credits: [],
details: new Map()
}
const data = req.body.data || req.body;
const credits = await CheckRegister.getReconcileCredits({
propertyID: data.propertyID,
});
returnData.credits = credits;
for(const c of credits) {
const paymentDetails = await TenantTransactions.getPaymentDetails(parseInt(c.CheckRegisterID));
let description = '';
for(const pd of paymentDetails) {
description += `Tenant: ${pd.tenantFName} ${pd.tenantLName} . Amount: $${parseFloat(pd.TransactionAmount).toFixed(2)}<br/>`;
returnData.details.set(parseInt(c.CheckRegisterID), description);
}
}
return res.json(returnData);
When I check it in postman, the array data is returned, but the map is an empty object. However, when I console.log()
the map before returning, it is a valid map with data.