JavaScript Asynchronous Programming with JavaScript Understanding Promises Handle Multiple Promises with Promise.all

Wikipedia Disambiguation page causes, "promises.js:47 TypeError: Cannot read property 'source' of undefined"... Fix?

So line 35: <img src=${person.thumbnail.source}> throws an error that causes only one with block to load on the page... The page works without the images, if I take the line out... I have had other problems with this error with this section. I've also seen some there people running into this as well, but haven't been able to find a good solution.

Also, please don't point me to the solution in the next section...(why did you wait to put it there?)

function generateHTML(data) {
  data.forEach( person => {
    const section = document.createElement('section');
    peopleList.appendChild(section);
    // Check if request returns a 'standard' page from Wiki
    if (person.type === 'standard') {
      section.innerHTML = `
        <img src=${person.thumbnail.source}>
        <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}
      `;
    }
  });
}

It gave me three blocks with non-displayed images with alt text and descriptions like: Sergey Ryzhikov Results unavailable for Sergey Ryzhikov

Sergey Ryzhikov may refer to:

Sergey Ryzhikov (cosmonaut), Russian cosmonaut Sergey Ryzhikov (footballer), Russian football player

1 Answer

wc93
wc93
24,882 Points

The course is being updated. Today Guil added changes that get it closer to what it is meant to be. Unfortunately the api that list the people on the ISS gives names that are not compatible/specific enough to target the wiki api summary pages for all of the crew. I was trying to figure out how to add the term "naut" or "ISS" to assist the wiki api targeting but have moved on at this point.