Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda