I'm using the Facebook SDK to implement login.
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
console.log(response);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + response.email + response.id + '!';
});
FB.api('/me/permissions', function(response) {
console.log(response);
});
}
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>
The login is successful and the code above displays the name and id of the user. However, email is showing undefined. It is strange because when I inspect the response object returned for the permissions query, I see user_friends, email, and public_profile have all been granted. Why is email undefined then?