Я делаю 2 вызова БД внутри l oop ниже, чтобы получить элементы statsID
и countryCode
. Я записываю их обоих в l oop, и результат просто отлично. Однако сохраненный результат (переменная с именем withAdditionalData
) никогда не утешается после Promise.all()
. Это где-то застревает, и я не знаю почему. Спасибо за любую подсказку!
const body = d.data
const countriesWithNoCode = []
const withAdditionalData = await Promise.all(body.map(async (item) => {
//get stats_id
const statsM = new statsModel()
const statsID = await statsM.getStatsId(item.BeverageTypes.trim())
console.log(statsID) // is fine
//check if country can be found by 2-digit code
const countryCode = await statsM.getCountryCode(item.Country.toString().trim());
if(!countryCode){
countriesWithNoCode.push(item.Country.toString().trim())
}
console.log(countryCode) // is fine
return {item, item.countryCode: countryCode, item.statsId: statsID}
}))
//it never consoles the following / it never gets there
console.log('withAdditionalData')
console.log(withAdditionalData)