I'm using AngularJS 1.2.0. When I'm calling a webservice with $resouce the response variable is always empty. The webservice is called correctly and the webservice is sending the result to the browser. The problem is that (callback(response){}) response is always empty.
angular.module('app').factory('geoCoding',['$resource', function ($resource) {
return $resource('http://open.mapquestapi.com/geocoding/v1/address', {key: getGeoKey()}, {
locate: {method: 'GET', isArray: false}
});
}]);
$scope.getLocations = function (locationName) {
return geoCoding.locate({location: locationName}).$promise.then(
function (response) {
log.log('response ', response);
if (response && response.data && response.data.results && response.data.results[0]) {
var locations = [];
response.data.results[0].locations.forEach(function (location) {
locations.push({name: geoUtils.location2String(location), location: location});
});
return locations;
} else {
return {};
}
}, function (error) {
log.error('Locations Query error: ', error);
});
};
I've created a plunker which shows $resource callbacks being logged working with similar code to yours here: http://plnkr.co/edit/o7hjbd3H2vl2LuHBjI8O?p=preview
When I used the URL you have above I got an ORIGIN error and the request wasn't being made successfully, so I've demonstrated with a response.json stub instead.