Our current approach involves storing short strings as keys.
These keys are linked to longer values, which serve as labels.
I am attempting to update the corresponding longer value for each key.
However, a problem arises where console.log(record) always executes first before the inner log statement. This results in an unmodified record being sent back to the getRadioValues function caller.
My goal is to ensure that the record is returned only after the corresponding key has been updated successfully.
export const getRadioValues = (record: IRecordInput) => {
const singleSelectKeys = ['Race', 'DeathWas', 'MannerOfDeath'];
singleSelectKeys.forEach(async key => {
if (record[key]) {
const dropDownOption = await DropDownOptions.find({ where: { id: record[key] }}) as IPDFSelect;
record[key] = dropDownOption.dataValues.Text;
console.log(record[key]);
}
});
console.log(record);
return record;
};