Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Christian Delos Reyes
9,199 PointsI'm not getting all the astronauts
I was only able to retrieve 3 of the 6 astronauts. This is what my page page looks like:
3 Answers

Daniel Barros
Front End Web Development Techdegree Graduate 23,588 PointsHi Christian,
I had the same issue when I did it. I found that it is due to those astronauts not having a complete record come through from the Wikipedia API. I tweaked a bit the function so that it didn't show only the blank tile. See below how I added the HTML in an if statement and the else part is what creates the tile for astronauts who don't have a complete record coming through from the wiki API.
Have a look at my code below and see if it works for you. And let us know if it does!
Cheers, Daniel.
// Generate the markup for each profile
function generateHTML(data) {
const section = document.createElement('section');
peopleList.appendChild(section);
if (data.type === "standard") {
section.innerHTML = `
<img src=${data.thumbnail.source}>
<h2>${data.title}</h2>
<p>${data.description}</p>
<p>${data.extract}</p>
`;
} else {
section.innerHTML = `
<h2>${data.title}</h2>
<p>No description available</p>
`;
}
}

James Roberts
16,976 PointsI had the same problem and the if statement inside the generateHTML function worked. Thanks Daniel. What does "standard" represent in the parameter of the if statement? (person.type === "standard)

Nuno Martins
5,512 Pointsfunction generateHTML(data) {
data.map( person => {
const section = document.createElement('section');
peopleList.appendChild(section);
section.innerHTML = `
<img src=${person.thumbnail.source}>
<h2>${person.title}</h2>
<p>${person.description}</p>
<p>${person.extract}</p>
`;
});
}
This doesn't work when the first astronaut fails to load, so using the @Daniel Barros 's code will fix the problem. +++
Daniel Barros
Front End Web Development Techdegree Graduate 23,588 PointsDaniel Barros
Front End Web Development Techdegree Graduate 23,588 PointsSorry, here is the code with Promise design instead.
Christian Delos Reyes
9,199 PointsChristian Delos Reyes
9,199 Pointsthanks! it worked