Here is my code:
var name;
function getFBName(username) {
$.getJSON('http://graph.facebook.com/' + username, function (d) {
name = d.name;
});
}
getFBName("zuck");
console.log(name);
I am struggling since hours but I can't get the getFBName
function to return the name of the user.
This is the JSON btw:
{
"id": "4",
"first_name": "Mark",
"gender": "male",
"last_name": "Zuckerberg",
"link": "https://www.facebook.com/zuck",
"locale": "en_US",
"name": "Mark Zuckerberg",
"username": "zuck"
}