My code:
var locations = {"testurl1", "testurl2"}, results = [];
locations.forEach(function(location,index){
request.get(location,function (error, response, body){
if (!error && response.statusCode == 200) {
var jsonResponse = JSON.parse(body);
results.add(jsonResponse.address);
}
}
})
console.log(results);
The results are printed as blank due to asynchronous get request. How can i make this work so I have all addresses in results?