Status 200 data undefined angularjs

0

I am mounting an application in angular, where I give http.get in a url, the status comes 200, but the date comes empty. In the api where I mounted, I return the array in json, and in the webservice in the angular, I apneas give http.get and the date returns me empty.

Here is the code for my service:

myApp.service('cinemas',function($http){

    return ({
        getList:getCinemasList
    });

    function getCinemasList(){
        return $http.get("http://api.localhost:8080/movie/204").then(function(response){
            console.log(response.data);
        });
    }
});
    
asked by anonymous 24.03.2016 / 23:28

1 answer

0

Try something like this:

.factory('MeuService', ['$http', '$q', function($http, $q) {
 var URL = "MinhaUrl";
return {
    getCinemas: function(){
     var deffered = $q.defer();
     $http({
          method: 'GET',
          url: URL
        }).then(function successCallback(response) {
            deffered.resolve(response.data);
          });
        return deffered.promise;
    }
}
}])
    
25.03.2016 / 00:13