diff --git a/lib/api/middlewares/error-middleware.js b/lib/api/middlewares/error-middleware.js index f4258383..645a8992 100644 --- a/lib/api/middlewares/error-middleware.js +++ b/lib/api/middlewares/error-middleware.js @@ -4,7 +4,6 @@ module.exports = function errorMiddleware (/* options */) { return function error (err, req, res, next) { const { logger } = res.locals; const errors = populateLimitErrors(Array.isArray(err) ? err : [err]); - let statusCode = findStatusCode(errors[0]); logger.error({ errors }); @@ -14,7 +13,7 @@ module.exports = function errorMiddleware (/* options */) { }; // If a callback was requested, force status to 200 - res.status(req.query.callback ? 200 : statusCode); + res.status(req.query.callback ? 200 : findStatusCode(errors[0])); if (req.query && req.query.callback) { res.jsonp(errorResponseBody);