I have a question about axios and error handling. So this is the method I'm using to handle errors when the user logins from the front end:
axios.post('http://localhost:3001/login',
{
login: user.login,
password: user.password,
}
)
.then(
(response) => {
// code
},
(error) => {
// error handling
}
);
This is the second method:
axios.post('http://localhost:3001/login',
{
login: user.login,
password: user.password,
}
)
.then(
(response) => {
// code
}
).catch((error) => {
// error handling
});
What is the best approach? Is it the same? When the server is unreachable the error message is the same: "Network Error". Is there any way to get a more detailed error? (For example in the console I get a CORS error)