JavaScript Asynchronous Programming with JavaScript Understanding Promises From Callbacks to Promises

Jason Pallone
Jason Pallone
11,242 Points

No promise objects are being returned?

My code is exactly the same ( I confirmed this by literally copying and pasting from the project files final code ) but no promise objects are being returned. With the normal AJAX request it will display the astronauts as normal. But when using a promise, it gets rejected and returns nothing.

promises.js:20 GET https://en.wikipedia.org/api/rest_v1/page/summary/Hazzaa%20Ali%20Almansoori 404 Error at XMLHttpRequest.xhr.onload (promises.js:15)

is the exact error i'm getting. So it's saying 404 for this astronaut and I figure that is crashing the program? Any suggestions?

2 Answers

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,369 Points

For testing purposes I just updated getProfiles in promises.js

function getProfiles(json) {
  const profiles = json.people.map( person => {

    if (person.name == "Hazzaa Ali Almansoori") {
      return getJSON("https://en.wikipedia.org/api/rest_v1/page/summary/Hazza_Al_Mansouri")
    }
    else {
      return getJSON(wikiUrl + person.name);
    }      
  }); 
  return profiles;
}

and it was logged as resolved. But ideally this is something that would be updated at the site.

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,369 Points

The name is currently spelled differently on wikipedia so would need to be updated. This link returns the page:

https://en.wikipedia.org/api/rest_v1/page/summary/Hazza_Al_Mansouri

Jason Pallone
Jason Pallone
11,242 Points

How would I update that name specifically? Or is that something their site needs to update? Thank you for the response!