[Solved] $http.get(…).success is not a function

i have this code:

app.controller('MainCtrl', function ($scope, $http){
    .success(function (data, status, headers, config){

In my local enviroment, works ok, but in a server, return this error:

TypeError: $http.get(…).success is not a function

Any ideas? Thanks

Solution #1:

The .success syntax was correct up to Angular v1.4.3.

For versions up to Angular v.1.6, you have to use then method. The then() method takes two arguments: a success and an error callback which will be called with a response object.

Using the then() method, attach a callback function to the returned promise.

Something like this:

app.controller('MainCtrl', function ($scope, $http){
      method: 'GET',
      url: 'api/url-api'
   }).then(function (response){

   },function (error){


See reference here.

Shortcut methods are also available.

$http.get('api/url-api').then(successCallback, errorCallback);

function successCallback(response){
    //success code
function errorCallback(error){
    //error code

The data you get from the response is expected to be in JSON format.
JSON is a great way of transporting data, and it is easy to use within AngularJS

The major difference between the 2 is that .then() call returns a promise (resolved with a value returned from a callback) while .success() is more traditional way of registering callbacks and doesn’t return a promise.

Solution #2:

This might be redundant but the above most voted answer says .then(function (success) and that didn’t work for me as of Angular version 1.5.8. Instead use response then inside the block got me my json data I was looking for.

    method: 'get', 
    url: 'data/data.json'
}).then(function (response) {
    console.log(response, 'res');
    data =;
},function (error){
    console.log(error, 'can not get data.');
Respondent: Ian Poston Framer

Solution #3:

If you are trying to use AngularJs 1.6.6 as of 21/10/2017 the following parameter works as .success and has been depleted. The .then() method takes two arguments: a response and an error callback which will be called with a response object.

 $scope.login = function () {
        $scope.btntext = "Please wait...!";
            method: "POST",
            url: '/Home/userlogin', // link UserLogin with HomeController 
            data: $scope.user
         }).then(function (response) {
            console.log("Result value is : " + parseInt(response));
            data =;
            $scope.btntext = 'Login';
            if (data == 1) {
                window.location.href = '/Home/dashboard';
            else {
        }, function (error) {

        alert("Failed Login");

The above snipit works for a login page.

Respondent: Waheed Rafiq

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy