mesaugat / express-api-es6-starter

Build APIs with Express.js in no time using ES6/ES7/ESNext goodness.

Home Page:https://express-api-es6-starter.herokuapp.com/api-docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

async / await on controllers

duard opened this issue · comments

Why you dont use async / await on controllers ?

/**
 * GET /api/users
 */
router.get('/', (req, res, next) => {
try { 
  resources = userService.getAllUsers();
  return resources;
} catche(error) {
  res.json(error);
});

Because promises are fine. Async await is just a wrapper around Generators and Promises. You are free to do what you want.