Created
          May 23, 2024 19:24 
        
      - 
      
- 
        Save ChrisMoney/41001f27af44feb51a75b5eee8eead01 to your computer and use it in GitHub Desktop. 
    JS Await and Async
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function resolveAfter2Seconds() { | |
| return new Promise((resolve) => { | |
| setTimeout(() => { | |
| resolve('resolved'); | |
| }, 2000); | |
| }); | |
| } | |
| async function asyncCall() { | |
| console.log('calling'); | |
| const result = await resolveAfter2Seconds(); | |
| console.log(result); | |
| // Expected output: "resolved" | |
| } | |
| asyncCall(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment