I want to create a factory that always returns the json object retrieved from a webservice:
angular.module('test').factory('myService', myService);
myService.$inject = ['$http'];
function myService($http) {
var urlBase;
return {
getContent: function(id) {
return $http.get(urlBase).then(function(response) {
return response.data;
});
}
};
}
When I call MyService.getContent();, I'm not getting the JSON object, but an object with $$state and __proto__.
Why? How can I fore the factory to directly return the content only?
Note: I know I could write
MyService.getContent().then(function(response) {
console.log(response);
});
but this way I'd always have to repeat the then... function statement when I access the factory.