File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,20 @@ const fetchPhotoDetails = (photo) => {
26
26
} ) ;
27
27
} ;
28
28
29
- fetchUser ( "Shubham" )
30
- . then ( ( user ) => fetchUserPhotos ( user . username ) )
31
- . then ( ( photos ) => fetchPhotoDetails ( photos [ 0 ] ) )
32
- . then ( ( details ) => console . log ( `Your photo details are ${ details } ` ) ) ;
29
+ // This was one way of calling the function
30
+ // fetchUser("Shubham")
31
+ // .then((user) => fetchUserPhotos(user.username))
32
+ // .then((photos) => fetchPhotoDetails(photos[0]))
33
+ // .then((details) => console.log(`Your photo details are ${details}`));
34
+
35
+ // The second way is using Async ==> Await
36
+
37
+ const displayData = async ( ) => {
38
+ const user = await fetchUser ( "Shubham" ) ;
39
+ const photos = await fetchUserPhotos ( user . username ) ;
40
+ const details = await fetchPhotoDetails ( photos [ 0 ] ) ;
41
+
42
+ console . log ( details ) ;
43
+ } ;
44
+
45
+ displayData ( ) ;
You can’t perform that action at this time.
0 commit comments