Node JS Convert 404 API Route to Proper Message
We Generally Face A Problem of Bad Error Handling If Route Not Found in Node JS, Let's See How Can We Fix This
![]() |
Error Handling in Node JS |
//404 error handling
app.use((req,res) => {
const error = new Error("Not found.")
req.code = 1
req.statusCode = 404
ResponseMiddleware(req, res, error.message)
})
That's it !
Happy Coding !
Comments
Post a Comment