1

这是我处理所有 API http 调用的网络服务。我需要创建一个缓存机制来缓存从其他服务调用的两个 API 调用。我怎样才能从这个公共服务中实现这一点?

   angular.module('abc').service('network', [
      '$http', '$rootScope', '$location', 'toast', function($http, $rootScope, $location, toast) {
        var get, post;
        post = function(url, data) {                
            return $http({
              url: url,
              method: "post",
              data: data,
              headers: {
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
              }
            }).then(function(result) {               
                return result.data;
              }
            });
          }
        };

    ]);
4

0 回答 0