Repetir uma chamada Restangular em um interceptador
A documentação oficial retangularfornece este exemplo de código para tentar novamente uma solicitação no ErrorInterceptor:
var refreshAccesstoken = function() {
var deferred = $q.defer();
// Refresh access-token logic
return deferred.promise;
};
Restangular.setErrorInterceptor(function(response, deferred, responseHandler) {
if(response.status === 403) {
refreshAccesstoken().then(function() {
// Repeat the request and then call the handlers the usual way.
$http(response.config).then(responseHandler, deferred.reject);
// Be aware that no request interceptors are called this way.
});
return false; // error handled
}
return true; // error not handled
});
No entanto, como diz nos comentários, a segunda tentativa não acionará nenhum interceptador porque ele usa $ http diretamente.
Existe uma maneira de fazer a segunda solicitação também passar pelo pipeline Restangular e executar o ErrorInterceptor?