I am trying to pass a JSON to another function in my Javascript code. But I am struggling to do so. I have included the simplified version of the code below.
function createJson() {
var det = {};
FB.api(
'/me',
'GET', {
"fields": "id, photos{id,name}"
},
function(response) {
console.log(response);
for (var i = 0; i < response.photos.data.length; i++) {
var obj1 = {
id: response.photos.data[i].id,
name: response.photos.data[i].name
};
det[i] = obj1;
}
}
);
getLikesJson(det);
From what I understand, I should now be able to work with 'det' within the function 'getLikesJson', instead I am getting [object Object]. Am I doing something wrong?