title: How to save and set headers on each request with Angular Interceptors
body: <p>I'm trying to setup token auth but can't seem to figure out a good way to save the headers the server is sending me into a cookie. I then need to read that value out of the cookie and into the new request headers.</p>
  
  <p>I'm using Angular 1.5</p>
  
  <p>Here's some simple code I've been trying to work with:</p>
  
  <pre><code>os.config(['$httpProvider', function ($httpProvider) {
  
    return {
     'request': function(config) {
  
         var access_token = $cookies.get('access-token');
         var token_type = $cookies.get('token-type');
         var client = $cookies.get('client');
         var uid = $cookies.get('uid');
  
          $httpProvider.defaults.headers.post['access-token'] = access_token;
          $httpProvider.defaults.headers.post['token-type'] = token_type;
          $httpProvider.defaults.headers.post['client'] = client;
          $httpProvider.defaults.headers.post['uid'] = uid;
  
      },
  
      'response': function(response) {
  
         $cookies.put('access-token', 'oatmeal');
         $cookies.put('token-type', 'oatmeal');
         $cookies.put('client', 'oatmeal');
         $cookies.put('uid', 'oatmeal');
  
      }
    };
  
  }]);
  </code></pre>
  
  <p>EDIT: People have been commenting trying to show me how to set headers. I can do that easily, as you can see in the example. What I need to do is save the response headers after I've made a request. These need to be saved into a cookie which is what my question pertains to.</p>
  
  <p>I'm interested in a method that doesn't require me to run some function in the .then part of every single API request I do, that's not DRY and seems like madness...</p>