Created the error middleware
This commit is contained in:
parent
5c65842cae
commit
b64bca6a81
5
server/middlewares/error.js
Normal file
5
server/middlewares/error.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = (err, req, res, next) => {
|
||||||
|
if (!(err instanceof SyntaxError)) return next();
|
||||||
|
|
||||||
|
res.status(400).json({message: "You need to provide a valid JSON body"});
|
||||||
|
}
|
Reference in New Issue
Block a user