zoukankan      html  css  js  c++  java
  • Angular $httpProvider

     timeout超时响应

    .factory('timestampMarker', ["$rootScope", function () {
        var timestampMarker = {
            'request': function (config) {
                config.timeout = 15000;
                return config;
            }
        };
        return timestampMarker;
    }])
    
    
    .config(['$httpProvider',function ( $httpProvider) {
            //设置调用接口超时
            $httpProvider.interceptors.push('timestampMarker');
    }])

    设置request和response

    .factory('logTimeTaken', [function () {
        var logTimeTaken = {
            request: function (config) {
                config.requestTimestamp = new Date().getTime();
                return config;
            },
            response: function (response) {
                response.config.responseTimestamp = new Date().getTime();
                return response;
            }
        };
        return logTimeTaken;
    }])
    
    
    .config(['$httpProvider',function ( $httpProvider) {
           $httpProvider.interceptors.push('logTimeTaken');
    }])
  • 相关阅读:
    MVP 实战
    Model 层
    Presenter 层
    View 层
    DB数据库的基本操作
    MongoDB数据库基本操作
    转换函数
    字符串函数
    空值处理
    Java中使用Redis的几种数据类型总结
  • 原文地址:https://www.cnblogs.com/maoyazhi/p/8989125.html
Copyright © 2011-2022 走看看