Wednesday, 3 May 2017

Express vs Koa with async/await?

I'm having trouble understanding what the main difference between Express and Koa is. I understand that Koa comes with no middleware and is a lot lighter, but is that the main difference?I know that Koa allows you to use async functions for middleware, but what's to stop you from doing the same thing in Express?For example changing this:app.use((req, res) => { doAsync().then(() => { ... }); }); to something like this:app.use(async (req, res) => { await doAsync(); ... }); Would this not work with Express? If not, then how can one know when it is okay to pass an async function as opposed to a normal function?

Submitted May 03, 2017 at 09:18PM by inhwjs

No comments:

Post a Comment