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

JavaScript Asynchronous Programming with JavaScript Understanding Promises Perform Cleanup With finally()

The HTML update in catch block is not updated upon passing incorrect URL

The code inside catch block is not executed upon passing incorrect astrosUrl My code looks like this

btn.addEventListener('click', (event) => {
  event.target.textContent = "Loading..";
  getJSON(astrosUrl)
  .then(getProfiles)
  .then(generateHTML)
  .catch(err => {
    peopleList.innerHTML = '<h3>Somethings not correct</h3>';
    console.log(err.response);
  })
  .finally(() => event.target.remove());
});

Instead, I get net::ERR_NAME_NOT_RESOLVED in chrome console

Update: After running a text diff between the promise.js within the Project Files and my promise.js it appears that my particular problems was related to incorrectly writing this line of code:

xhr.onerror = () => reject( Error('A network error occurred') );

If you are experiencing the same problem, it may be worth taking a look at this line again. If that doesn't help, then perhaps running a text diff like I did.

Original: I am also experiencing this same exact issue despite trying all the steps in the article linked by rydavim with the exception of using a VPN.

Chrome is giving the following error:

GET http://api.openwe-notify.org/astros.json net::ERR_NAME_NOT_RESOLVED

FireFox is giving me this error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://api.openwe-notify.org/astros.json. (Reason: CORS request did not succeed).

1 Answer

rydavim
rydavim
18,813 Points

I'm not particularly familiar with Chrome, but it looks like it might be an issue with your browser rather than with your code.

I would try going through the steps in this article and see if that solves the problem.