Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSwan The Human
Full Stack JavaScript Techdegree Student 19,338 PointsSite not running correctly. loading button does not appear and only three astro profiles show up.
As soon as I added the async to "const profiles = peopleJSON.people.map( async (person) =>" . all of the variables below changed color like they weren't declared correctly or something. and then when I ran the preview, on click the load button shows up but never disappears and only three of the astros show up. I reviewed my code like ten times and then went ahead and downloaded the final code from the project files and pasted it in as well and I'm getting the same results.
When I ran devtools to check what happened with the click response i got an error saying "Uncaught (in promise) TypeError: Cannot read property 'source' of undefined"
6 Answers
Ryan Waite
7,678 PointsI'm guessing theres something wrong with the API, try removing the img tag from the generateHTML function
Daven Hietala
8,040 PointsAfter deleting the img tag completely I was able to load the 6. Thanks Ryan.
Adam Sturchio
3,500 Pointsafter removing the image i was able to load everybody except Hazzaa Ali Almansoori
Brian Mikol
5,423 PointsYes, the code is not robust enough to handle astronaut wiki pages that don't have a profile picture; it completely breaks when it hits that astronaut's wiki page in parsing. I haven't been able to figure out a way to ignore the person.thumbnail.source
part of the code if there isn't a picture in order to make the code less brittle – so really the only way around this is if you pull that part of the code out entirely (at least until someone volunteers a working solution).
Mark Maconachie
7,878 PointsIt may be because there are only 3 astronauts in space right now. The JSON that comes back seems quite well formed, although one of the current entries is ambiguous i.e. there are multiple entries for the name "Andrew Morgan" in the wiki. A little fudging of the data will make sure the right info comes back down e.g. // Get the astronaut profiles from wikipedia function getProfiles(data) { data.people.map(person => { console.log("person :", person); person.name = person.name == "Andrew Morgan" ? "Andrew R. Morgan" : person.name; getJSON(wikiUrl + person.name, generateHTML); }); }
Stan Byford
9,388 PointsSince introducing fetch, await and async the code is no longer working either.
Sukanya Charuchandra
Full Stack JavaScript Techdegree Student 547 PointsAn easy work around is to, in the function that generates the HTML, write the call back function within the map method to only run if person.thumbnail exists. It'll look something like this below:
someVariable.map( person => { if(person.thumbnail){
//write in whatever you planned to within here! Hope this helps!
} })
wc93
25,725 PointsProblem is the names retrieved in astrosUrl api fetch do not correspond directly to wikipedia pages because of differences in the names. Currently I get 3 of the 7 ISS crew. Go to : http://api.open-notify.org/astros.json and see what is returned. Then add those names to the end of: https://en.wikipedia.org/api/rest_v1/page/summary/ Look at the JSON and You get a person.type of disamibigutaion or no-extract Adjust your generateHTML function to account for a type other than standard
So a middle initial or Kate instead of Kathleen or two Sergey Ryzhikovs mess up the direct link to the wikipedia api pages on the cosmo/astro-nauts.
Daven Hietala
8,040 PointsDaven Hietala
8,040 PointsI second this experience. Same thing here not sure what to do about it.
One other thing is that my button does not disappear. Instead it stays in the 'Loading...' state. I had to comment out my catch err like so in order load anything at all and just got the first three like you.
I'll try what Ryan suggested..
Sorry I couldn't give any more useful info.