Advertisement
izznogooood

Untitled

May 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2.  
  3. const app = express();
  4. const port = 3000
  5.  
  6. const somePromise = (txt) => {
  7.     return new Promise((resolve, reject) => {
  8.         setTimeout(() => {
  9.             if (txt === 'crash') {
  10.                 reject('crashed!')
  11.             }
  12.             resolve('Some Text');
  13.         }, 2000);
  14.     });
  15. };
  16.  
  17.  
  18. const doSomething = async () => {
  19.     const result = await somePromise('crash')
  20. }
  21.  
  22.  
  23. app.listen(port, () => {
  24.     console.log(`Server running on port ${port}...`);
  25. });
  26.  
  27. doSomething()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement