Recently, I started utilizing angular-cache and stumbled upon this question on stack overflow. The user was inquiring whether the ngResource transformResponse function is executed before caching. It turns out that it isn't.
However, is there a workaround for this limitation? When my API responds with an object containing excessive information that I don't need for caching purposes, how can I extract only the IDs I require?
My idea is as follows:
app.factory('Operator', function($resource, API_CONFIG_URL, CacheFactory) {
var opsCache = CacheFactory.get('manageableOperatorsCache');
return $resource(API_CONFIG_URL+ '/operators/:id', {id: '@id'}, {
'get': {
method:'GET',
transformResponse: function(data, headers) {
// Transforming the object into this format: ids: [1, 2, 3]
},
cache: opsCache
},
});
});
Thank you for your assistance :)