Delay an angular.js $http service

前端 未结 8 1125
感动是毒
感动是毒 2021-01-31 16:32

I have some angular factories for making ajax calls towards legacy ASP.NET .asmx web services like so:

module.factory(\'productService\', [\"$http\",
function ($         


        
8条回答
  •  日久生厌
    2021-01-31 16:35

    Developing more on the answer of @stevuu

    responseInterceptors seems to be depreceted (as of 1.2.20) I have modified the code to work on the interceptors mechanism:

    $httpProvider.interceptors.push(function($q, $timeout) {
        return {
            'response': function(response) {
                var defer = $q.defer();
                $timeout(function() {
                            defer.resolve(response);
                    }, 2300);
                return defer.promise;
            }
        };
    });
    

提交回复
热议问题