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.

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
221,107 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...