Unable to Access User's email. Getting "Undefined"
facebook, facebook-javascript-sdk, facebook-login
Solution
you probably don't have email permission even though you think you do.
Try,
FB.login(function(){
FB.api('me',
function(response){
console.log(response.email);
});
},{'scope':'email'});
Problem
I have a website with the Facebook login implementation. My app has the permission for the user's email. Even though the user logs into my app using Facebook I can only retrieve his/her name or basic info. Not the email. So, here's the code I literally copied from the Facebook Developers Website: ``` window.fbAsyncInit = function() { FB.init({ appId : 'xxxxxxxxxxxxxxx', // App ID channelUrl : '//domain.org/channel.html', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); FB.Event.subscribe('auth.authResponseChange', function(response) { if (response.status === 'connected') { testAPI(); } else if (response.status === 'not_authorized') { FB.login(); } else { FB.login(); } }); }; // Load the SDK asynchronously (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); function testAPI() { console.log('Welcome! Fetching your information.... '); FB.api('/me', function(response) { console.log('Good to see you, ' + response.email + '.'); }); } </script> ```