When I click the button I send to the server and then the server responds to me but I can’t show it in Chrome console I can only see the response in the network tag.
Client:
const Login = async (e) => {
e.preventDefault();
await axios
.post("http://localhost:5000/login", { userLogin })
.then((res) => {
console.log(res);
});
};
Server:
app.post("/login", (req, res) => {
const { email, password } = req.body.userLogin;
User.findOne({ username: email }).then((user) => {
user.password == password
? res.json("Login successfully")
: res.json("Your password or username is wrong");
});
});
Network tag:
Can you guys help me please 🙁
2
Answers
you can use
console.log(res.data);
You should return a json object like that
You can then show your error in browser console like that