This workshop will be retired on August 31, 2026.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Working with the Fetch API!
You have completed Working with the Fetch API!
Preview
What would happen if a fetch gets rejected or returns in a failed state? To handle these types of errors, you use the catch() method, which deals with rejected cases only.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
But what would happen if a fetch gets
rejected or returned in a failed state?
0:00
For example, if a user is offline,
the API server is down,
0:02
or the API just doesn't have an image for
the selected value?
0:06
To handle these types of errors,
you use the catch method,
0:10
which deals with rejected cases only.
0:14
Back in our project,
0:17
let's chain a catch method to the end
of one of the fetch data sequences.
0:18
I'll chain it to the first
one with .catch.
0:23
And now if there's ever
an error fetching this data,
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up