I have an API returning the following response
{
"keyA": [1,2,5],
"keyB": [3,6,4],
"keyC": [3,2,1]
}
And I'm using a very simple service to access the API endpoint
var $module = angular.module('mySimpleService', ['ngResource']);
$module.service('MyApiService', function(
$resource
){
return {
entities: $resource('http://myapi.com/data', null, {
'get': {
method: 'GET',
isArray: false,
responseType: 'json'
}
})
};
});
And I'm calling the service like this
var apiData = MyApiService.entities.get()
.$promise.then(function(data){
console.log(data);
console.log(Object.keys(data));
});
When I log out the data and the object keys, I can see that angular has added $promise
and $resolved
as properties to my data. Since I need to enumerate the keys, this is a bit inconvenient.
Am I missing a crucial step here? How can I access my raw untainted response?