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 trial

Kay Wrobel
2,635 PointsGetting a type error of undefined for person.thumbnail causes Promise .catch() to trigger + Solution
This question relates to the course "Asynchronous Programming With JavaScript" in the "Understanding Promises" section. I do not know how to add more tags to this Question. Maybe a moderator can assist.
Following this example in 2025, and there seems to be a person in space that does not have a thumbnail. Thus, the string template inside generateHTML
function fails for the <img>
tag as it refers to an undefined thumbnail. The console also logs this.
A possible solution is to wrap the assignment of the <img>
template string to person.innerHTML
inside a conditional.
// Generate the markup for each profile
function generateHTML(data) {
data.map( person => {
const section = document.createElement('section');
peopleList.appendChild(section);
section.innerHTML = ''; // Initialize as blank
// Check if request returns a 'standard' page from Wiki
if (person.type === 'standard') {
// Some people do not have a thumbnail, and so person.thumbnail is undefined
// This causes the .catch() on the Promise object to trigger!
if (person.thumbnail) {
section.innerHTML += `<img src=${person.thumbnail.source}>`;
}
section.innerHTML += `
<h2>${person.title}</h2>
<p>${person.description}</p>
<p>${person.extract}</p>
`;
} else {
section.innerHTML += `
<img src="img/profile.jpg" alt="ocean clouds seen from space">
<h2>${person.title}</h2>
<p>Results unavailable for ${person.title}</p>
${person.extract_html}
`;
}
});
}
1 Answer

Travis Alstrand
Treehouse Project ReviewerThanks for sharing your awesome solution! 🎉😃
Typically, you can click the Questions tab underneath a video to post in the forum and have it directly related to that video 👍
Thanks again!