Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
JavaScript - Problem getting data from promise object

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

User = [];
FBInstant.player.getDataAsync(['name']).then(function(data) {
    User['name'] = data['name'];
    console.log(User['name'])
});

This should give you a response

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!