I have an array of 4 urls and each url has json data. how to loop through urls
ex :
urls =[ "http://url1.com",
"http://url2.com", "http://url3.com", "http://url4.com"];
each url has json one student information like
{ date: 08/05/2014
studentname: 'xyz'
student marks:[
maths:80
science:60
]
}
now i want to loop through all 4 urls in this case 4 students information to get all student marks at once(means some thing like all information into one object]so later i can parse and find out which student has got the highest marks or lowest marks ? how this can be done in node.js ?
https://github.com/mikeal/request https://github.com/caolan/async#map
var async = require('async');
var request = require('request');
async.map(urls, function(url, callback) {
request(url, function(err, response, body) {
callback(err, body);
})
}, function(err, students){
if(err) {
return console.error(err);
}
//Do sth. with students array
});