D
D
Dubolom Unicellular2020-07-16 22:20:46
JavaScript
Dubolom Unicellular, 2020-07-16 22:20:46

Express.js - why doesn't work after .status().json()?

I tried to return json + status 400 from the server (code snippet, indents fell off):

if(!login) {
   return res.status(400).json({ message: "Введите логин" });
}
if(!email){
   return res.status(400).json({ message: "Введите Эл. Почту" });
 }

 const candidate = await User.findOne({ login });
 if(candidate) {
    return res.status(400).json({ message: "Такой аккаунт уже существует" });
 }


All res.status'y at first return null, then undefined at the client

without .status() everything works, but only the status 200 that does not correspond to the truth. How to fix this!?

(In another project, I did the same trick with .status and everything works 0_0 there)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question