Answer the question
In order to leave comments, you need to log in
Why is error status returned, but json file is not returned with it?
There is a piece of code that is responsible for authorizing the user. If I return a status with an error code, then Jason does not come with a message, if the status is removed, then everything is OK. How can I make it come and this and that? Not strong in backing...
UserModel.findOne({email:postData.email},(err,user: any) =>{
if(err || !user) {
return res.status(404).json({
message:"error"
});
}
if(bcrypt.compareSync(postData.password, user.password)){
const token = CreateJWT(user);
res.json({
status:"success",
token
})
} else {
res.json({
status:"error",
message: "Неудача.. "
})
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question