Promise.all(allLangs.slice(0, 5).map(async e =>{
try {
const wikiIntro = await getWikipediaIntro(e.title, e.lang);
const objectName = await extractObjectName(e.lang, wikiIntro);
const currLang = await Promise.all(objectName.map(async obj=>({
origLang: e.lang,
origNameCountry: obj.country,
origName: obj.name ,
url: e.url,
targetLang,
translation: await translateWithGpt(e.lang, targetLang, obj.name)
})));
return currLang;
} catch (error) {
console.error(error);
return {
origLang: e.lang,
error: error.message
}
}
}))