Guest User

ads

a guest
Jan 6th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function wait( sleep ) {
  2.     return new Promise( ( resolve , reject ) => {
  3.         setTimeout( () => {
  4.             resolve();
  5.         } , sleep );
  6.     } );
  7. }
  8.  
  9.     async index( req , res ) {
  10.  
  11.         await wait( 1000 );
  12.         console.log( 'a' );
  13.  
  14.         await wait( 2000 );
  15.         console.log( 'b' );
  16.  
  17.         await wait( 3000 );
  18.         console.log( 'c' );
  19.  
  20.         await wait( 4000 );
  21.         console.log( 'd' );
  22.  
  23.         res.send( 'Hello world!' );
  24.  
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment