I have the following loops which make 10 requests. The console.log
would print from 1 to 10. How do I modify this code to only print out the final length of peopleProfile
(10)?
for (var i = 0; i < 10; i++) {
request(URL, function(err, response, body) {
if (err) {
console.log(err);
}
if (!err && response.statusCode == 200) {
peopleProfile.push(body);
console.log(peopleProfile.length);
}
});
}