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
Elisa Burghard9,276 Points
page for one astronaut not found, so nothing shows up at all
Console shows: GET https://en.wikipedia.org/api/rest_v1/page/summary/Hazzaa%20Ali%20Almansoori 404
I am guessing that since we use Promise.all() it waits for all the requests to come back resolved and only then the results are displayed. Since one request is rejected, it also does not display the ones that are resolved?
How can you solve this, if the problem lies within the GET request using the API?
No problem! your enjoing the courses so far? in which course are u? Im currently doing the php track
Yes, so far it's a good track. I know python as well but i dont know php seem to be more less complex to work with compare to node.js and python
Brendan Moran14,052 Points
The least hacky way to fix this is by using
Promise.allSettled() instead of
Promise.all(). In the first line of your generateHtml function, you will want to console.log the data to see what it looks like, because it's a little different. You'll set up a test to see if
person.status === 'fulfilled'. If so, on the first line of your "if" block, just reassign person to equal person.value. The rest of your code can stay the same, go ahead and build your html. If
person.status === rejected', you can just skip building any html, or you could do some creative error handling that is more useful to the client.