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.
I've tracked down:
$http.defaults.headers.common['Authorization'] = 'Basic ' + login + ':' + password);
I've tried:
.config(['$http', function($http) {
$http.defaults.headers.common['Authorization'] = 'Basic ' + login + ':' + password);
}])
As well as appending it directly to the request:
$http({method: 'GET', url: url, headers: {'Authorization': 'Basic auth'}})})
But nothing works. How to solve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…