0

I am trying to consume a webservice(Get method )in angularjs.

I have written the code in controller using $http. But, i am not getting any response back, and also i am not sure whether it had hit the URL or not.

All the Corrections or suggestions about the below code are welcome.

(function() { 'use strict';

angular
    .module('ilSaasApp')
    .controller('HomeController', HomeController);

HomeController.$inject = ['$scope', 'Principal', 'LoginService', '$state', '$http'];

function HomeController ($scope, Principal, LoginService, $state, $http) {

    function userinfo(){
        alert("Hello");

        $http.get('http://52.38.106.96/Test_Service/WDS_SERVICE.svc/userregistrationbymultipleuseridsforapp/UserIDs?UserIDs=931')
        .then(function(response) {
            alert("Inside fun");
         $scope.data = response.data;

        });

    }
}

})();

1
  • 1
    When the request is timed-out or aborted, the response is an error with status -1. Commented Apr 19, 2017 at 12:16

1 Answer 1

1

Just Write error block.. Then check.

    function userinfo(){
http.get('http://52.38.106.96/Test_Service/WDS_SERVICE.svc/userregistrationbymultipleuseridsforapp/UserIDs?UserIDs=931')
            .then(function(response) {
                alert("Inside fun");
             $scope.data = response.data;
            }, function(error){
            console.log(error);
    }
    });
Sign up to request clarification or add additional context in comments.

2 Comments

I tried with that. Getting the below response. Object {data: null, status: -1, config: Object, statusText: "", headers: function} Any idea about this ?
When the request is timed-out or aborted, the response is an error with status -1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.