I want to catch the error from the bodyParser() middleware when I send a json object and it is invalid because I want to send a custom response instead of a generic 400 erro
what I did was just:
app.use(bodyParser.json({ limit: '10mb' })) // body parser error catcher app.use((err, req, res, next) => { if (err) { res.status(400).send('error parsing data') } else { next() } })