I decided to try async / await, but ran into a problem:

router.get('/api/bookmarks-theme/', async function a (req, res, next) { ^^^^^ SyntaxError: missing ) after argument list 

.babelrc:

 { "presets": ["es2015", "stage-3"], "plugins": [ "add-module-exports", "transform-async-to-generator", "syntax-async-functions", "transform-regenerator", "transform-runtime" ] } 

Method in the route:

 router.get('/api/bookmarks-theme/', async function a (req, res, next) { BookmarkTheme.find({}, (err, data) => { if (err) return next(err); res.json(data); }); }); 

What is the problem ?

  • one
    try the usual function and not the switch - Grundy
  • router.get ('/ api / bookmarks-theme /', async function a (req, res, next) => {^^^^^ SyntaxError: missing) after argument list - Khotey Vitaliy
  • So why there => ? - Grundy
  • removed, the same thing - Khotey Vitaliy
  • Add updated code to question with indication of error - Grundy

0