score:1

Accepted answer

In you example you are combining both of await and .then(), I would use only one of them.

Preferably await as the following:

try {
   const dict = await getDictionaryByKey(fieldValue.value.entityDefinitionCode);
   const dictItem = dict.find((item) => fieldValue.value.entityId === item.code);
   acc[fieldName] = dictItem ? dictItem.text : fieldValue.value.entityId;
} catch (err) {
   acc[fieldName] = fieldValue.value.entityId;
}

Related Query

More Query from same tag