I'm trying to do an error management in express as per the form input from frontend. I saw that either I can send res.status(401) as error code or res.json({}) as sending error message but not both. What should I do below here to send both simultaneously?
app.post('/verifyOTP', (req, res) => {
const hash = req.body.hash;
let [ hashValue, expires ] = hash.split('.');
let now = Date.now();
if (now > parseInt(expires)) {
return res.status(400).json({ error: 'Timeout. Please try again' })
}
})