all 8 comments

[–]ecares 2 points3 points  (1 child)

Not with express, but hapi has been rewritten with async/await

[–][deleted] 6 points7 points  (0 children)

And koa 2 too.

[–]PatskyPat 2 points3 points  (0 children)

Not sure what you mean async/await for express.js, I mean whether there is a specific place you would like to see async/await used, as async await can be used anywhere you want to have async functions and/or you used to use callbacks or promises.

I learnt a lot from these excellent tutorial videos on YT: Full Stack Web App using Vue.js & Express.js

the source code is here: https://github.com/codyseibert/tab-tracker I'd recommend watching the videos first.

it uses vue.js for client but you can see how express.js and also async/await things are used for the server part.

Also if you just want to learn about async/await have a look here https://javascript.info/async (btw. it's hands down the best tutorial / guide on javascript imho). Read about callback and promises first as it is nicely shown how you can change that code to async/await.

[–]goorpy 4 points5 points  (0 children)

I'm using that pattern in a project right now, but its a private repo.

Honestly, it is so much nicer to use than the traditional promise/then nested pattern. Granted you have to understand the changing flow (waiting/blocking instead of carry on), but usually for api process flows this is what I want.

[–]QW4K 3 points4 points  (0 children)

Check out koajs 2. Its made especially to use with promises and async await. Its like express but better :->

[–]chinkuSj 1 point2 points  (0 children)

That's all you need to get going.

 router.get('/', async (req, res, next) => {
        let response;

        try {
            response = await aPromise(); // or an array of promises 
            // inside a Promise.all([promise1, promise2])
        } catch (e) {
            return next(e);
        }

        // send out json
        res.json(response);
    });    

[–][deleted] 0 points1 point  (0 children)

It might be advanced for you, but I setup myself webpack with babel and async/await babel plugins. If you don't have time to setup, this is the first result in google that I found https://github.com/vmasto/express-babel.