title: React Redux error Unhandled Rejection (TypeError): Cannot read property 'data' of undefined
body: <p>I'm using axios with react redux. I get this error when there is successful post.Is this the right way to handle error in axios and redux. If not please guide me.My reference links <a href="https://www.npmjs.com/package/axios" rel="nofollow noreferrer">axios</a> ,<a href="https://stackoverflow.com/questions/35439019/redux-promise-with-axios-and-how-do-deal-with-errors">how to deal with errors</a> , <a href="https://github.com/axios/axios/issues/376" rel="nofollow noreferrer">error handling in axios</a> .If this question seems obvious ,i apologize.I'm beginner.Thanks in advance.</p>
  
  <pre><code>export const landingPageValues=(values)=&gt;{
    return dispatch=&gt;{
      return axios.post('http://127.0.0.1:8000/mainData',values)
        .then(res=&gt;{dispatch(mainpageuploadsuccess(res.data))})
        .catch(err=&gt;{dispatch(mainpageuploadfailed(err.response.data.error))})
    }
  }
  export const mainpageuploadsuccess = (data) =&gt;{
    return {
      type:'MAINPAGE_UPLOAD_SUCCESS',
      mainUploadData:data
    }
  }
  
  export const mainpageuploadfailed = (error) =&gt;{
    return {
      type:'MAINPAGE_UPLOAD_FAILED',
      error
    }
  }
  </code></pre>
  
  <p>Reducer </p>
  
  <pre><code>case 'MAINPAGE_UPLOAD_SUCCESS':
    const {mainUploadData} = action;
    return {
      ...state,
      mainUploadData,
      error:false
    };
  
    case 'MAINPAGE_UPLOAD_FAILED':
    const {error} = action;
    return {
      ...state,
      error,
      mainUploadData:false
    };
  </code></pre>