Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const app = express();
- const port = 3000
- const somePromise = (txt) => {
- return new Promise((resolve, reject) => {
- setTimeout(() => {
- if (txt === 'crash') {
- reject('crashed!')
- }
- resolve('Some Text');
- }, 2000);
- });
- };
- const doSomething = async () => {
- const result = await somePromise('crash')
- }
- app.listen(port, () => {
- console.log(`Server running on port ${port}...`);
- });
- doSomething()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement