Facebook API – Login with the JavaScript SDK

I´ve seen a lot of weird coding happening around Login with the Facebook JavaScript SDK, so here is one good solution with explanation. HTML (just a login button and a div for the response) <button id=”loginBtn”>Facebook Login</button> <div id=”response”></div> JavaScript function getUserData() { FB.api(‘/me’, {fields: ‘name,email’}, (response) => { document.getElementById(‘response’).innerHTML = ‘Hello ‘ + response.name; … Continue reading Facebook API – Login with the JavaScript SDK