cornflourblue / react-redux-registration-login-example

React + Redux - User Registration and Login Tutorial & Example
https://jasonwatmore.com/post/2017/09/16/react-redux-user-registration-and-login-tutorial-example
MIT License
1.19k stars 760 forks source link

TypeError: Cannot read property 'then' of undefined #16

Closed kerembeyazit closed 5 years ago

kerembeyazit commented 5 years ago

Hi.

I changed the fetch api to axios and am gettin this error.

user.service.js login function;

function login(email, password) {
    let bodyFormData = new FormData();
    bodyFormData.set('email', email);
    bodyFormData.set('password', password);

    axios({
        method: 'POST',
        url: appVars.apiURL + 'api/public/login',
        data: bodyFormData,
        config: {headers: {'Content-Type': 'multipart/form-data'}},
    })
      .then(response => {
          console.info(response);
          localStorage.setItem('user', JSON.stringify(response.data.data.token));
      })
      .catch(function (response) {

      });
}

I changed username strings to email in user.actions.js login function.

My API response

Thanks.