I
I
Ilya Pavlov2017-07-30 19:51:13
JavaScript
Ilya Pavlov, 2017-07-30 19:51:13

Error handling in async/await nodejs?

When processing a regular promise:

asyncFun()
  .then(function(done){ 
    // done
  })
  .catch(function(error){
    // error
  })

And how to handle the error in this case:
var f = async(function(){
  var a = await(asyncFun());
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
myspace, 2017-07-30
@PiCoderman

async getAllMembers(id) {
        try {
            return await model.query('select * from `group_members` where `group_id` = ?', [id]);
        } catch(e) {
            return e;
        }
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question