I am experiencing an issue when trying to receive Spring validation from my back end to the front end.
I have the back end validation set up and when testing in postman I receive the correct messages for each field, that I am validating.
Here is an example from Postman:
My URL - http://localhost:8080/login
The body that I am sending -
{
"username": "",
"password": ""
}
And then the answer that I receive -
{
"password": "Password is required",
"username": "Please type in your username."
}
However when I try to login my web app, I receive error 400 - bad request. And that's the only error I receive, here is a picture of the network tab when logging in. Network tab image
I tried using a normal fetch post, without axios, but I got the same outcome, so I reverted back to axios.
I am always being send to the error catching of the try, catch block if I try to submit empty fields and my code cannot reach the error handling. Or at least that's what I am thinking.
Here is my front-end code, I feel like the issue is something very obvious, unfortunately couldn't find anything on the internet.