I am passing in an array into a function, if "facebookValue" is present then acquire user id and access token.
The function works properly in that the id's can be output into console ... but my problem seems to be the return values are not capturing the variables, i get undefined.
Here is my function
function facebook_oAuth(arr){
var checkArray = $.inArray('facebookValue', arr),
uid,
accessToken;
if (checkArray == -1) {}
else{
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
uid = response.authResponse.userID,
access_token = response.authResponse.accessToken;
console.log(uid + " ? " + accessToken); // ok
}
return [uid, access_token];// doesnt return the values from above
});
}
};
And i'm acquiring the values like this, but the values (uid,accessToken) come out undefined
var myReturn = facebook_oAuth(myArray),
uid = myReturn[0],
accessToken = myReturn[1],
credentialsArray = [uid,accessToken];