Ahhhhh, I got it…
I’m waiting for an array of promises than a promise. So the function returns an array of Promise objects instead of a Promise. I have to use the function Promise.all
return await Promise.all(companies.map(async (company) => {
return await strapi.query('companies').findOne({'id': company.company_id});
}))
So, the final solution is:
let entities = await Promise.all(companies.map(async (company) => {
company.company = await strapi.query('companies').findOne({'id': company.company_id});
}))
Best,
Thorsten