title: Stuck on understanding asyncHandler on Nodejs
body: <p>I am currently stuck on understanding how asyncHandler really works. I understand that asyncHandler is a wrapper method for controller methods so that we don't have to write try/catch on every method that we call on controller or services/repo (that is a good dry). I also understand that async/await returns promises so </p>
  
  <pre><code>return Promise.resolve(fn(req, res, next)).catch(next);
  </code></pre>
  
  <p>is acting as a try/catch.
  below is the full script of asynchandler</p>
  
  <pre><code>var asyncHandler = function (fn) {
   return function (req, res, next) {
     return Promise.resolve(fn(req, res, next)).catch(next);
   };
  };
  
  module.exports = asyncHandler;
  </code></pre>
  
  <p>what I dont understand is how 
  <code>return function(req,res,next)</code> 
  is working?</p>