【发布时间】:2018-05-05 12:47:01
【问题描述】:
目前我们将短字符串存储为键。
这些键对应于作为标签的长值。
我正在尝试更新键的相应长值。
但是 console.log(record) 总是先执行,然后执行内部日志语句,这是不希望的。它总是将未修改的记录发送给 getRadioValues 函数调用者。
我想在对应的key更新后返回记录。
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;
};
【问题讨论】:
标签: javascript typescript ecmascript-6 async-await