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
My .catch() method is not throwing an error in the console.
See my snapshot: https://w.trhou.se/ba289en5fb
ChatGPT thinks it should log to console just fine but I've removed the catch method with a mistyped URL and my console looks the same:
GET https://dog.ceo/api/basdfa/image/random 404
GET http://port-80-hv98rdr4ku.treehouse-app.com/No%20route%20found%20for 404 (Not Found)
Jamie ReardonTreehouse Project Reviewer
Hi Samuel Kleos, the reason it is not going into your
catch method is because from the promise's point of view, it has still fulfilled. If you log out the
response in the
then method (which you can see is where the promise goes instead of the catch), you will see that the response
ok property is
false, and the status property is
404. It would be up to you to code out the logic at this point inside the
then method to throw an error so that the
catch method would then be called.