I tested react login page on my Iphone by accessing my PC's ip address.when i hit login button it gives me following error every time without showing error toast. in my pc's chrome browser its working perfectly in mobile view.
Unhandled Rejection (TypeError): undefined is not an object (evaluating 'error.response.data')
is this a CORS related security issue?if i push app to production will this error be resolved?
please help me to figure out the situation. this clickSubmit method is called when i submit login form this image shows the error occurred in real mobile device, same thing is happening when i try to access my local server using another laptop via same wifi network
const clickSubmit = event => {
event.preventDefault();
setValues({ ...values, buttonText: 'Submitting' });
axios({
method: 'POST',
url: `${process.env.REACT_APP_API}/signin`,
data: { email, password }
}).then(response => {
console.log('SIGNIN SUCCESS', response);
authenticate(response,()=>{
// save the response (user, token) localstorage/cookie
setValues({ ...values, name: '', email: '', password: '', buttonText: 'Submitted' });
// toast.success(`Hey ${response.data.user.name}, Welcome back!`);
isAuth() && isAuth().role === 'admin' ? history.push('/admin') : history.push('/private');
})
})
.catch(error => {
console.log('SIGNIN ERROR', error.response.data);
setValues({ ...values, buttonText: 'Submit' });
toast.error(error.response.data.error);
});
};