I am making an app and right now I am coding the backend with express js in node js. For some reason, It is saying that the username and password is invalid.
app.get("/signUp", async (req, res) => {
const json = req.body;
const user = await UserModel.findOne(json["username"])
if(!json["username"] || json["username"] === "" || !json["password"] || json["password"] === "") {
return res.status(400).send({
"status": 400,
"message": "Username and/or password is empty. New user was not created"
})
}
else if(user.type != null) {
return res.status(409).send({
"status": 409,
"message": "User already exists with given username. New user was not created."
})
}
else {
await UserModel.create({
username: json["username"],
password: json["password"]
})
return res.status(200).send({
"status": 200,
"message": "New user was created."
})
}
})