I'm using express framework to grab links from some webpage, and I add this links to Array
. I'm using async
to print final result but when I print my array I gets list of objects.
Result of collate function:
Finall: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Objec
t]
How can I iterate of this array of objects? This is my code:
router.route('/send')
.post(function(req, res){
async.series([ function(callback){
var url = req.body.url;
var items = [];
console.log(url);
if(url.length>=1) {
if (isURL(url)) {
console.log('OK');
res.sendStatus(200);
request(url, function(err, resp, body){
$ = cheerio.load(body);
links = $('a.offer-title');
$(links).each(function(i, link){
items[i] = new itemParam($(link).text(),12)
});
callback(false, items);
});
} else {
errorHandling(res, 401,"Invalid url");
}
}else{
errorHandling(res, 401,"Invalid url");
}
}
],
/*
* Collate results
*/
function(err, p) {
console.log("Finall: " + p[0]);
}
);
});