Wednesday 19 September 2018

How should I handle unhandled promises node.js?

Should I do:Todo.find().then((todos)=>{ res.render('home', {todos}); },(e)=>{ res.status(400).send(e); }); Which means passing an arrow function to catch an error, or:Todo.find().then((todos)=>{ res.render('home', {todos}); }).catch((e)=>{ res.status(400).send(e); }); Remove the arrow function to catch an error and use a catch promise?

Submitted September 19, 2018 at 03:17PM by its_joao

No comments:

Post a Comment