Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
error handler Unexpected block statement surrounding arrow body

I'm following a node/express course and the instructure has written the below error handler code and I get the error:

Unexpected block statement surrounding arrow body; move the returned value immediately after the =>.eslintarrow-body-style

Any ideas how to fix it?

enter image description here

const catchAsync = fn => {
    return (req, res, next) => {
        fn(req, res, next).catch(next)
    }
}


exports.createTour = catchAsync(async (req, res, next) => {

    const newTour = await Tour.create(req.body);

    res.status(201).json({
        status: 'success',
        data: {
            tour: newTour
        }
    })
})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

ref here: https://eslint.org/docs/rules/arrow-body-style

So, Depends on your eslint configuration, it could be

const catchAsync = fn => (req, res, next) => fn(req, res, next).catch(next)

or

// return keyword at nested block
const catchAsync = fn => {
    return (req, res, next) => {
        return fn(req, res, next).catch(next)
    }
}

I guess the fix is the 2nd example

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda