The problem can be a simple thing or a complex thing, but in what I'm seeing it seems that you have not declared the variables outside the function. I suggest you do something like this and see if you continue to have an undefined exit:
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 have internal outputs, but you can do 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);