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

JavaScript

Sam Brown
Sam Brown
9,796 Points

Uncaught TypeError: Cannot read property 'source' of undefined

I found that some of the wiki data returned was for 'disambiguation' pages, e.g. the name refers to multiple pages, so the generateHTML function was failing with the above error.

There will be a better solution but to complete the exercise I skipped these astronauts with a conditional (person.type != 'disambiguation').

// Generate the markup for each profile function generateHTML(data) { data.map( person => { if (person.type != 'disambiguation') { const section = document.createElement('section'); peopleList.appendChild(section); section.innerHTML = <img src=${person.thumbnail.source}> <span>${person.craft}</span> <h2>${person.title}</h2> <p>${person.description}</p> <p>${person.extract}</p> ; } }) }

Steven Parker
Steven Parker
229,644 Points

Tip: If you post using the "get help" button on a course page, it should get a link button to that page, but more importantly it will appear on that page's "questions" tab. This will make your message much easier for students to find.

Sam Brown
Sam Brown
9,796 Points

Thanks Steven Parker I'll re-post this to the page questions...