export const startLogin = (email, password) => {
return async (dispatch) => {
try {
const response = await axios.post('/admins/login', {email, password})
if( response.status === 201 ) {
dispatch(Login(response.data.token))
return response
}
} catch(error) {
if(error.response && error.response.status === 400) {
console.log(error.response.data)
return Promise.reject(error.response.data.error)
} else if(error.request) {
console.log('Request error: ', error.request)
} else {
console.log(error.response)
}
}
}
}
I am trying to handle 400 bad request error upon user login. I get the desired response error message from my nodejs server. but the problem is I am also getting a weird console error message that says:
POST http://localhost:3000/admins/login 400 (Bad Request) xhr.js:178
and i tried everything i could do, catching all the errors like above but it didnt work. what could be the problem here?
How can i handle this console error gracefully? Any help would be appreciated. Thanks