$http Auth Headers in AngularJS

前端 未结 8 726
闹比i
闹比i 2020-11-30 21:52

I have an angular application that is hitting a node API. Our backend developer has implemented basic auth on the API, and I need to send an auth header in my request.

8条回答
  •  醉梦人生
    2020-11-30 22:23

    You can use it in the controller:

    .controller('Controller Name', ['$http', function($http) {
       $http.defaults.headers.common['Authorization'] = 'Basic ' + login + ':' + password;
    }]);
    

提交回复
热议问题