vendredi 27 mars 2015

Variable is null after setting value on FB.api function

I'm trying to get the user locale and keep it on a variable.



function myFunction() {

var userLocale;

FB.api(
"/{userID}",
function (response) {
if (response && !response.error) {
userLocale = response.locale;
}
}
);

}


When i set userLocale with the value that gives me the function, the console.log(userLocale); returns undefined.


myFunction is called after check if the user has access to my app.


Aucun commentaire:

Enregistrer un commentaire