async await middleware

yknam·2023년 9월 23일
0
[원본](https://www.acuriousanimal.com/blog/20180315/express-async-middleware)
const asyncHandler = fn => (req, res, next) =>
  Promise
    .resolve(fn(req, res, next))
    .catch(next)
    
app.get('/hello', asyncHandler( (req, res, next) => {
  // Some code here. Any error will be catch and pass to expressjs
}) );
profile
50대 개발자 노드, 자바스크립트

0개의 댓글