我想在返回数据之前等待异步功能getPreprocessed运行,以使消息不会被不确定
data: result.rows.map(notification => {
var message
const entity_type_id = notification.entityTypeId
const preProcess = entityTypeDetails[entity_type_id].process;
async function getPreprocessed() {
let processedData = []
const promise = entityTypeDetails[entity_type_id].preProcessing
for (let index = 0; index < promise.length; index++) {
const element = promise[index];
const processed = await element.process(notification)
processedData.push(processed)
}
processedData = Object.assign({}, ...processedData.map(object => (object)))
message = res.__(entityTypeDetails[entity_type_id].messageProp,processedData)
}
getPreprocessed()
return {
message: message,
notification_notifiers: notification.notification_notifiers[0]
}
})