The problem may be a simple thing or a complex thing, but from what I’m seeing it seems you haven’t declared the variables out of function. I suggest you do something like this and see if you still have a way out Undefined:
var nome;
var foto;
FB.api('/me', function(response) {
FB.api('/me/picture?type=normal', function(response) {
foto = response.data.url;
});
nome = response.name;
});
console.log(foto);
console.log(nome);
Internal Methods, usually has internal outputs, but vc can make an external output by calling another method, as the example below:
var valores = [];
FB.api('/me', function(response) {
FB.api('/me/picture?type=normal', function(response) {
valorEntrada(response.data.url, 0);
});
valorEntrada(response.name, 1);
});
function valorEntrada(valor, pos) {
valores[pos] = valor;
}
function valorSaida(pos) {
return valores[pos];
}
var foto = valorSaida(0);
var nome = valorSaida(1);
console.log(foto);
console.log(nome);
Possible duplicate: http://answall.com/q/60852/129
– Sergio