【问题标题】:Restangular - $http interceptorsRestangular - $http 拦截器
【发布时间】:2014-05-29 14:59:35
【问题描述】:

早上,

我有一个 $http 拦截器:

app.factory('Unauthed', ['$q', 'alertService',function($q,alertService) {
    return {
        response: function (response) {
            if (response.status == 401) 
                alertService.error('Authentication failure.',15000);

            return response || $q.when(response);
        }
    };
}]);

这对于所有通过 $http 但不通过 Restangular 的请求运行良好。浏览酸痛的 Restangular 使用 $http 所以我不确定这里发生了什么?

干杯

【问题讨论】:

  • 这不应该发生,但也许 restangular 正在使用 .call() 或 .apply() 并且它在名为 response 的变量和名为 response 的方法之间感到困惑?

标签: angularjs restangular


【解决方案1】:

也许执行顺序很重要,你在哪里注册restangular?也可能是角度模块的依赖顺序,尝试将restangular声明为子模块的依赖项,但不在主应用程序模块中,以便在添加restangular时已经装饰了$http。

【讨论】:

    猜你喜欢
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多