Created
February 25, 2016 00:53
-
-
Save icfantv/ecf185f55e0a28ed624a to your computer and use it in GitHub Desktop.
Angular HTTP Interceptors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('app', []); | |
app.config(['$httpProvider', ConfigureInjectors]); | |
function ConfigureInjectors($httpProvider) { | |
$httpProvider.interceptors.push('InterceptorService'); | |
} | |
app.service('InterceptorService', ['$cookie', InterceptorService]); | |
function InterceptorService($cookie) { | |
this.request = function(config) { | |
} | |
this.requestError = function(rejection) { | |
} | |
this.response = function(response) { | |
// set your auth token on the $cookie service here. | |
} | |
this.responseError = function(rejection) { | |
} | |
} |
mu-arch
commented
Feb 25, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment