Cannot read property 'then' of undefined - AngularJS

246 views Asked by At

I want to include Asp.Net Identity into my app.

But when I want to register a new user, I get an error on javascript side:

Cannot read property 'then' of undefined.

This is the code in my Controller: When I click the button to register the user, I get in the function below.

$scope.signUp = function () {

     AuthenticationService.register($scope.registerData).then(function (response) {
        ...
      },
      function (response) {
         ...             
      });
  };

And this is the code in my Service, which is called in the Controller above.

     register: function (registerData) {            
        this.logout();
        Restangular.all('api/account/register').post(registerData);            
     }

What am I doing wron? Can you help me to get the solution?

1

There are 1 answers

1
Oguzhan On BEST ANSWER

Your service method does not return the promise of what Resangular.all().post() is supposed to return. Its a q promise.

 register: function (registerData) {            
    this.logout();
    return Restangular.all('api/account/register').post(registerData);  
    //return $http.post("api/account/register", {data:registerData})
 }