Im having a weird behavior manipulating a response through $resource with a custom interceptor.
If I use a response interceptor like this :
angular.module( 'app.services', [] )
.factory( 'Product', function( $resource, routesConfig ) {
return $resource( routesConfig.catalogueEndPointg(), {}, {
query: {
method :'GET',
isArray : false,
params : {
page : '@currentPage'
},
interceptor: {
response: function( response ) {
// DO STUFF
return response;
}
},
}
});
});
Then, from my controller :
angular.module( 'app.controllers', [])
.controller( 'DummyController', function( $scope, Product ){
productsPromise.$promise
.then(
// Success
function ( response ) {
console.log( response );
});
});
At this point, this is the output of the console.log( response ) :
On the response object, I have the data object, as expected, but I also have this resource : Resource object which also includes the response data again.
But, if I dont use a interceptor at all; Im getting the expected response :
I dont understand this behavior and Im concern about perform or memory issues.
Can somebody clarify this ?
PS: I need to use interceptors, because I have to modify the response from server.