react-facebook icon indicating copy to clipboard operation
react-facebook copied to clipboard

How to do FB.api('me/accounts',function(response){ console.log('res',response); }); this with our package ?

Open vengatbap opened this issue 6 years ago • 2 comments

How to do FB.api('me/accounts',function(response){ console.log('res',response); }); this with our package ?

vengatbap avatar Feb 11 '20 21:02 vengatbap

New to this myself, but have been obsessing as of late. I was able to return information using the following:

  const handleLoginResponse = function (res) {
         window.FB.api("/me/accounts", function (result){
            console.log(result)
        });
    }

The above method is attached to the onCompleted of the login component:

<Login scope="email" onCompleted={handleLoginResponse} onError={handleError}>
     ...
</Login>

UPDATED: Originally used lambda/arrow functions ( )=>{ } which causes a timing issue because it changes the scope.

benbakle avatar Feb 12 '20 15:02 benbakle

@benbakle Thanks It's working now

vengatbap avatar Feb 13 '20 21:02 vengatbap