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!
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
the importance of creating the checkstatus function if catch on the fetchData function is already returning errors?
what is the importance of creating the checkStatus function for errors while catch on the fetchData function is already checking if there are erros? i am very confused
Steven Parker228,001 Points
At about 2:48 in the video, the instructor says "Since fetch is only concerned with sending a request and receiving a response from the server, we should also provide a way of checking for and handling failed HTTP responses."
What he means is that while the catch method responds to errors related to getting any kind of server response, it does not react to a response that is successfully received, but it contains a code indicating that the server encountered a problem while processing the request.
Similar to how the first type of error was demonstrated by misspelling the "api" part of the request URL, you can demonstrate this other kind of error by misspelling the "random" part of the URL.