0

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);
        });
};
paduz
  • 21
  • 5
  • I'm certain this issue is unrelated to teact-toastify. Can you post a [Minimal, Complete, and Reproducible Code Example](https://stackoverflow.com/help/minimal-reproducible-example) so we may see what your code is doing? It's very difficult to help debug code if you can't see it. – Drew Reese Jun 27 '21 at 19:34
  • hello Drew.. thank you so much for helping me. i updated my question with code and attached image. this error only appears when i am trying to access my locally hosted app via remote devices which are connected into same wifi network. otherwise my locally hosted server working perfectly without any issues. can this be a accessibility related issue? when i push into real production server will this error happen again? – paduz Jun 28 '21 at 05:52

0 Answers0