I overlooked the API. I changed the method 'cookieexpirycheck' to 'request'.
It is working. Is there a way to print the response cookies ? HTTP-only 
cookies are not accessible. Right ? Other cookies can be printed. 

Thanks.

On Monday, 9 March 2015 19:33:08 UTC+5:30, Mohan Radhakrishnan wrote:
>
> Hi,
>
>           I may be missing the obvious here. The interceptor is not fired 
> when I use $resource. I was trying to check my angular-cache whenever I get 
> a cookie to activate session expiry. But the usecase has nothing to do with 
> the firing of interceptors.
>
> .factory('sessionvalidator', ['$q',
>                               '$injector',
>                               '$cookies',
>
>   function( $q,
>             $injector,
>             $cookies,
>             LocalStorageService
>              ){
>     var sessionvalidator = {
>         cookieexpirycheck : function( response ){
>
>             //No need to use a Promise API here unless we want to do
>             //resume a request that is stopped due to cookie expiry
>             var cachebuster = $injector.get("CacheService");
>             var $http = $injector.get('$http');
>             var deferred = q.defer();
>
>             console.log( 'Cookie [' + $cookies.getAll().toJSONString() + ']');
>             console.log( 'Cache [' + cachebuster + ']');
>         }
>     };
>     return sessionvalidator;
> }])
> .config(['$httpProvider', function($httpProvider){
>     $httpProvider.interceptors.push('sessionvalidator');
> }])
> .factory("JSON", function($resource){
>     return $resource("http://localhost:3000/test";);
> })
> .controller( "externalAPIcontroller", [ '$scope',
>                                         'JSON',
>                                         'CacheService',
>                                       function( $scope,
>                                                 JSON,
>                                                 CacheService){
>     $scope.call = function externalquery() {
>         JSON.query(function (data) {
>             console.log('Data [' + data + ']');
>             console.log('CacheService [' + CacheService + ']');
>         })
>     }
> }]);
>
>
> Thanks,
>
> Mohan
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to