0
votes

I am creating a login page in react, when I submit incorrect values want the server response message text for status code 400. It just gives the below error: Error: Request failed with status code 400

axios

.post(
  "users/login",
  {
    email: user.email,
    password: user.password
  })
.then(res => {       
  return res.data;
})
.catch(err => {
  return err.message;
});

Need to get the error message text

1

1 Answers

0
votes

try to:

console.log(err.response)

you should see the the response from server and the message