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 Moran13,743 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.