1async function getUserAsync(name)
2{
3 let response = await fetch(`https://api.github.com/users/${name}`);
4 let data = await response.json()
5 return data;
6}
7
8getUserAsync('yourUsernameHere')
9 .then(data => console.log(data));
10
1function resolveAfter2Seconds() {
2 return new Promise(resolve => {
3 setTimeout(() => {
4 resolve('resolved');
5 }, 2000);
6 });
7}
8
9async function asyncCall() {
10 console.log('calling');
11 const result = await resolveAfter2Seconds();
12 console.log(result);
13 // expected output: 'resolved'
14}
15
16asyncCall();
17