Set defaults header on AngularJS but don't use it on one specific request

后端 未结 4 1239
半阙折子戏
半阙折子戏 2020-12-10 01:26

For sending OAuth2 token I am setting up defaults header on AngularJS like this:

$http.defaults.headers.common[\'Authorization\'] = \'Bearer \' + access_toke         


        
4条回答
  •  情深已故
    2020-12-10 01:51

    While the $httpProvider can override $http the use of intereceptors are 1 way of handling this, I end up doing it this way

    function getMyStuff(blah) {
    
            var req = {
                method: 'GET',
                url: 'http://...',
                headers: {
                    'Authorization': undefined
                }
            }
            return $http(req)
                .then(function(response) {
                    return response.data;
                });
    
    
    }
    

提交回复
热议问题