In koa, the use of next() allows for async middleware. It is not necessary, and actually creates unexpected behavior to use return next() within route handlers as it passes control flow to the next route that matches the request path, rather then returning the response. Going forward, next() is likely only needed in middlware, unless we have some special path chaining we are trying to do.
In koa, the use of
next()
allows for async middleware. It is not necessary, and actually creates unexpected behavior to usereturn next()
within route handlers as it passes control flow to the next route that matches the request path, rather then returning the response. Going forward,next()
is likely only needed in middlware, unless we have some special path chaining we are trying to do.