So, I'm new to using promise object... I'm trying to make a Facebook instant game which uses the function FBInstant.player.getDataAsync().then()
. This function returns a promise and I have no clue how to use the data returned other than with console.log()
. If I try to insert the data to a defined variable it becomes unidentified.
Example:
User = [];
FBInstant.player.getDataAsync(['name']).then(function(data) {
User['name'] = data['name'];
});
console.log(User['name']) // return unidentified.
Sorry for my poor explanation I'm new to this and I'm just trying to accomplish a simple task.