Hey I have written this code in node js
async function getUdemydata(){
try{
var finalData = []
const res = await axios.get(baseUrl)
const $ = cheerio.load(res.data);
$('div[class="content"]').each(async (i,el) =>{
const courseTitle = $(el).find("a").text()
const aa = $(el).html()
const courseUrl = await getCoupenCode($(el).find("a").attr("href"))
const courseDescription = $(el).find(".description").text().trim()
const courseImage = await formateImageUrl($(el).find(".image").html())
var dataObj = {
"title": courseTitle,
"description": courseDescription,
"image": courseImage,
"link": courseUrl
}
finalData.push(dataObj);
console.log('appended');
})
return (finalData);
} catch(error){
console.error(error);
}
}
(async()=>{
var rs = await getUdemydata();
console.log(rs);
})()
When I call the getUdemydata() function only the empty array is printed after that appended which is inside the function is being printed what should I change in the code so that the function will return the final array