Sup guys! This is the code on server side when something goes wrong:
return res.status(400).send({ error: 'Email already used!'});
And this is my frontend code that I try to catch the error message:
return async dispacth => {
try {
const res = await axios.post('http://localhost:3333/account/signin', userData);
localStorage.setItem('JWT_TOKEN', res.data.token);
dispacth({
type: AUTH_SIGN_IN,
token: res.data.token
});
} catch (err) {
console.log(err.message)
console.error('error', err);
dispacth({
type: AUTH_ERROR,
errorMessage: err.message
});
}
}
But this is what I got on browser's console:

err.response.body.error