Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!