• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Extract json data

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys, i have this assignment from my school, and ive tried to solve it for hours now.. Im able to fetch the Json, but when i try and print the names i get undefined every time.
Don't know why, since IMO, ive declared the variables im trying to extract.

Best Regards.

Assignment

Execution in serial
Use fetch and async/await to complete fetchPerson(..)below. When implemented, each line in printNames() must be executed “sequentially”. Verify this with the debugger.



What i have so far

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code on line 13 that calls fetchPerson expects the data to be returned from that function. Yet, looking at the code of fetchPerson reveals that there is no data returned.

Mystery solved.
 
Rune Møllehøj Hansen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope, still returns undefined.



Output

Before
undefined
undefined
After all

 
Rune Møllehøj Hansen
Greenhorn
Posts: 6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've fixed it. Thank you for your input.
 
reply
    Bookmark Topic Watch Topic
  • New Topic