I have this following code where I return comments for a post on facebook.
function pegaFoto(id){
var url2 = 'https://graph.facebook.com/v2.8/' + from[id] + '/picture?fields=url';
$.getJSON(url2, function(res2){
for (var key2 in res2.data) {
foto[id] = res2.data[key2].url;
console.log(res2.data[key2].url);
}
});
}
function refreshCounts() {
var url = 'https://graph.facebook.com/v2.8/********_*********/comments?fields=from{id}, message&access_token=' + access_token;
$.getJSON(url, function(res){
for (var key in res.data) {
comentario[key] = res.data[key].message;
from[key] = res.data[key].from.id;
pegaFoto(key);
console.log(comentario[key]);
console.log(foto[key]);
}
});
}
What is strange is that the second function works perfectly and the one above does not work. the variable url2 is being set correctly but $ .getJSON does not execute and I have no idea why