I am using the following functions:
function loop_perms(permissions) {
.... call check_perm here....
}
function check_perm(perm) {
var result;
FB.api(
{
method: 'users.hasAppPermission',
ext_perm: perm
}, function(response) {
result = response;
});
return result;
}
Now, the issue is that I am getting an undefined from the result of check_perm whereas in the Firebug console, I can see that response has a value of 0 or 1 (depending on perm)
Anyone knows what I am doing wrong? I am guessing it has something to do with the fact that i am trying to capture the value of a variable inside a callback.
Regards
Nikhil Gupta.
I assume the Facebook API is asynchronous. So at the time
return resultis executed, the callback was not called yet. You have to provide a callback from the calling function:and