2

나는 다음과 같은 코드가 작동하지 않습니다.각 응답의 인터셉터는 RestAngular

인터셉터는 partial과 내부 각도 물건을 가져 오지만 RestAngular 요청 ($ http에 대한 래퍼)에는 작동하지 않는 HTTP 요청에 대해서는 정상적으로 작동합니다.

도움을 주시면 감사하겠습니다.

답변

1

가능합니다. 약식으로 가로 채기가 작동하지 않습니다. 다음과 같이 $ q를 사용해보세요 :

var interceptor = ['$rootScope', '$q', function ($rootScope, $q) { 
    return { 
    'request': function(config) { 
     console.log("request successful"); 
     return config || $q.when(config); 
    }, 
    'requestError': function(rejection) { 
     console.log("request error"); 
     return $q.reject(rejection); 
    }, 
    'response': function(response) { 
     console.log("response successful"); 
     return response || $q.when(response); 
    }, 
    'responseError' : function(rejection) { 
     console.log(rejection.status+" something bad happened"); 
     $rootScope.errors = ["Unable to connect to server "+rejection.config.url]; 

     return $q.reject(rejection); 
    } 
    }; 

}]; 
+0

감사합니다. –