How to get "403 Forbidden" code response message through axios ?
I am working with a Token API with using of this JWT plugin :
It is working well with 200 status code. But how can i handle 403 Forbidden error message ? As currently i am not able to display an error message.
export const LoginAction = (FormData) => {
return (dispatch) => {
axios({
method: 'post',
headers: { 'Content-Type': 'application/json' } ,
url: API,
data: FormData,
})
.then(function (response) {
localStorage.setItem('tpwToken', response.data.token);
dispatch({
type: 'SET_USER',
user: response.data,
message: response.data.message
})
})
.catch(function(error){
console.log(error.message)
})
}
}