I have a function like this inside a NodeJs app
function dojob(url){
var resultList = [];
request (url, function (error, response, html){
if(!error){
var $ = cheerio.load(html);
$(".elements a").each(function(i, el){
resultList.push($(this).text()); //$(this).text() have values!!
});
}
});
return resultList; //but here it is empty
}
Now resultList will be always empty [], and return empty, how to work around this.