I send data to API with email and password. API Ruby on Rails with library devise-token-auth
signinform.js
......................................................
onSubmit(e){
e.preventDefault();
this.setState({errors: {}, isLoading: true});
this.props.userSignInRequest(this.state).then(
() => {console.log('ok!')},
({resp}) => { console.log(resp.errors); }
);
} .........................................................
actions/signInActions.js
import axios from 'axios';
export function userSignInRequest(userData){
return dispatch => {
return axios.post('/auth/sign_in', userData);
}
}
If email or password are incorrect i get response:
{"errors":["Invalid login credentials. Please try again."]}
But console.log(resp.errors); display undefined. If i put (resp) => { console.log(resp); }
I get in console:
Error: Request failed with status code 401 at createError (createError.js?16d0:16) at settle (settle.js?db52:18) at XMLHttpRequest.handleLoad (xhr.js?ec6c:77)
How me get errors in console.log(resp);