Node.js code to extract all the links from the web page and store it in the variable that stores the data inside the scope of the function but not showing the data outside the scope of the function.
var ineed = require('ineed');
var url = require('get-urls');
var list = require('collections/list');
var fs = require('fs');
var arr = [];
ineed.collect.hyperlinks.from("https://energy.economictimes.indiatimes.com/rss/", function (err, response, result) {
var links = url(JSON.stringify(result)).toArray();
var str="/rss/";
for(var i = 0; i<links.length; i++){
if((links[i].search(str))>-1){
arr.push(links[i]);
}
}
console.log(arr);
// I am getting the output of the array here
})
//While printing the array I am not getting the output
console.log(arr);