I'm trying to add Login with FB on my react website.
FB.init({
appId : app_id,
cookie : true,
xfbml : true,
version : 'v5.0'
});
Followed by
FB.getLoginStatus(({status}) => {
if (status === 'connected') {
FB.logout();
}
FB.login((response) => {
if (response.authResponse) {
const {authResponse: {accessToken}} = response;
onSuccess(accessToken);
} else {
onError({error: 'popup_closed_by_user'});
}
}, {scope: 'email'});
})
But it's opening the popup the first time (when getLoginStatus
is not connected
) and then the 2nd time it shows an error on the console
Uncaught b { innerError: undefined, message: "Expression is of type undefined, not function" }
Upon further investigation, I found that the error happens when the line FB.logout()
is called.
What might I be doing wrong?
NOTE The same code was working until yesterday.
It seems like FB.logout
now has reqired param: cb
.
https://developers.facebook.com/docs/reference/javascript/FB.logout/
Not sure when it became mandatory, but it is not working without it anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With