While working on creating a route in express.js with a try/catch block, I encountered an issue where the code would load without returning any value when the conditions in the try block are not met.
Has anyone found a solution for this problem?
app.post('/test', async (req, res) => {
try {
const {name} = req.body;
if (name === 'name') res.status(200).json({message: 'success!'}) // stuck at there
} catch (err) {
res.status(500).json({message: 'failed!'})
}
})