I am trying to integrate facebook login for my angular JS website. I am getting a pop up and even I am getting some data like my id and username. The issue what I am facing here is when I am trying to redirect the page or sending this data to a handleUser object in my controller, it is not allowing me to call any of the function from that fbLOgin() function block. It is not allowing me to call any function from dat block... please help me with this.
FBLogin(){
console.log("came into fb ");
FB.init({
appId : 'my_id',
autoLogAppEvents : true,
xfbml : true,
version : 'v2.9'
// js.src = "//connect.facebook.net/en_US/sdk.js";
});
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
// console.log('Good to see you, ' + response.name + '.');
console.log(response.name);
let user = {
"userAccountId":response.name,
"userRole": "CUSTOMER",
"lastOtpRequest": 0,
"fullName": "myname",
"mobileNo": "1234567890",
"emailId": "[email protected]",
"like": false,
"token": 0,
"loyal": false,
"guest": false,
"enabled": true,
"newCustomer": true
}
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}); }
Actually I am having the same problem with the gmail account also. So what I found here is, we cant call the current object from that promise. So I Created another function from that promise and I m calling that function. The code is as follows..