Advertisement
Guest User

Untitled

a guest
Jul 12th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. const sayHello = () => {
  2. return new Promise( (resolve, reject) => {
  3. setTimeout(() => {
  4. resolve('Hello world');
  5. }, 500);
  6. });
  7. }
  8.  
  9. // Declaring an async function
  10. const printHelloWorld = async () => {
  11. // Waiting for the promise to be resolved
  12. result = await sayHello();
  13. console.log(result);
  14. }
  15.  
  16. printHelloWorld();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement