I have a code in node - sails js mongo db code like this, it is for user signup: signup fn:
try{
let err;
let user = await User.create({req.body}).fetch();
if (!user){
throw new Error('Failed');
}
res.status(200).json({user});
}catch(e){
res.status(500).json({e.message});
}
};
req.body:
{
"firstName": "jay", // required
"lastName": "Thomas",
"email":"yo@gmail.com", // required and unique
"password": "X12345678", // required
"languages":["c++", "english"]
}
if I miss-spell the email to emal,
it should through a db error which it does and sends the response, but it also shows the error on the console, which I do not want. I only want it to send the error in response.
What changes I need for that?