[enter image description here][1]I have problems with async/await. in consolelog 1 ,consolelog 2 and consolelog 3 thanks for more
const getAnimEpisodesProm = async (URL) => {
return new Promise(async(resolve, reject) => {
const html = await http.loadHtml(URL);
const $ = cheerio.load(html.data);
const animEpisodes = [];
$("ul[id=episode_related]").find("a").each(async (_, element) => {
const Url = BUrl + $(element).attr("href").trim();
episodeId = $(element).find(".name").text().split(" ")[2];
await getEpisodeX(Url,episodeId).then(val => {
animEpisodes.push(val);
console.log(animEpisodes.length)
})
})
console.log(animEpisodes.length, "here")
resolve(animEpisodes);
});
}
outpute of code
0 'here'
[]
1
2
3
4
5