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 Asynchronous Programming with JavaScript!
You have completed Asynchronous Programming with JavaScript!
Preview
In this video, you will convert many of the project's promise chains to async/await.
Resources
Examples of async/await patterns
// Anonymous async function
(async function() {
const response = await fetch('...');
})();
// Async function assignment
const getData = async function() {
const response = await fetch('...');
};
// Arrow functions
const getData = async () => {
const response = await fetch('...');
};
// Async Function as an argument
btn.addEventListener('click', async () => {
const response = await fetch('...');
});
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
And make sure to update the script tag and
index.html to point to async-await.js.
0:00
So this new file contains the same global
variables we've worked with all along,
0:02
also the generateHTML function that
generates the mark up for each profile and
0:07
the addEventListener method.
0:11
Looking at where we left off in
the previous stage with fetchAPI,
0:14
you can see that we're calling fetch in
the EventListener to kick off an Ajax
0:17
request, then following a sequence of
then methods to manage and distribute
0:20
the return data to other functions in
the program like getProfiles for example.
0:25
So what we're going to do now
is write one async function
0:29
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