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 Practice Fetch API!
You have completed Practice Fetch API!
Preview
This video covers one solution to the challenge
Other Fun APIs
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
Keep watching to see my solution and
then go ahead and give it another try.
0:00
I started by creating a stub for
the getCountries function.
0:02
As we must wait for the API response,
0:06
I made the function asynchronous
by adding the async keyword.
0:08
To catch any issues we may encounter
while fetching the data, I'll wrap my
0:13
code in a try catch block, where any
errors will be logged to the console.
0:17
Let's look at the documentation to see
which URL we want to fetch the data from.
0:22
If we scroll down a bit
the information we need is here.
0:26
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