I'm using Node.JS to iterate through some data and push that data to an array. However, console.log does not seem to show any changes that I've made. I'd like to be able to process the data in twitter_ids after the function is done pushing data to it.
I'm wondering if it's due to a misunderstanding of Node.JS's asynchronous nature?
var twitter_ids = []
function sendResults (twitter_ids){
return function(data){
for (var num in data['results']) {
T.get('users/lookup', { screen_name: data['results'][num]['twitter_id'] }, function(err, data, response) {
twitter_ids.push(data[0]['id']);
});
}
console.log(twitter_ids);
}
}
sunlightResults.call(sendResults(twitter_ids));