Ashish Gupta
Ashish Gupta

Reputation: 11

$cacheFactory , api cache angular js

This is my network service from where I am handing all API http calls. I need to create a cache mechanism for caching two API calls which are called from other service. How can I achieve this from this common service?

   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;
              }
            });
          }
        };

    ]);

Upvotes: 1

Views: 32

Answers (0)

Related Questions