The same way you access name. i.e
response.email and response.id
but to fetch email address you must have the permission to access it.
Add scope="email" to your FB Login Button.
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
testAPI();
} else {
// cancelled
}
}, { scope: 'email' });
}
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.' + ' Email: ' + response.email + ' Facebook ID: ' + response.id);
});
}
Here's a good tutorial for beginners: http://www.loginworks.com/technical-blogs/404-working-with-facebook-javascript-sdk
i am not associate with above link to any promotion it is just for information
Also it is a privacy related issue.
above code will work only user enabled others to view his/her emails.