Vuelva a intentar una llamada Restangular en un interceptor
La documentación restangular oficial.proporciona este ejemplo de código para volver a intentar una solicitud en el 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
});
Sin embargo, como dice en los comentarios, el segundo intento no activará ningún interceptor porque usa $ http directamente.
¿Hay alguna manera de hacer que la segunda solicitud también atraviese la tubería Restangular y ejecute el ErrorInterceptor?