AngularJS error .success is not a function

See 'Deprecation Notice' from $http service documentation:

The $http legacy promise methods success and error have been deprecated. Use the standard then method instead.

You can learn more about these methods in the documentation about $q.


Here it is the code

Depricated code

$http(  
{  
    method: 'POST',  
    url: '/Home/CreateCustomer',   /*You URL to post*/
    data: $scope.cust   /*You data object/class to post*/
}).success(function (data, status, headers, config)  
{  

}).error(function (data, status, headers, config)  
{  

}); 

Allowed code Angular $http docs

$http(
    {
       method: 'POST',
       url: '/Home/CreateCustomer',  /*You URL to post*/
       data: $scope.cust  /*You data object/class to post*/
    }).then(function successCallback(response) {
       // this callback will be called asynchronously
       // when the response is available


    }, function errorCallback(response) {
       // called asynchronously if an error occurs
       // or server returns response with an error status.

});