Reputation: 11
The above screenshot is while I debug the web service which is hit during my javascript call. I want to set the authorization header of the http request which is returning null. Can you please suggest me for this
Upvotes: 0
Views: 4943
Reputation: 23816
You can add this in your http
request:
headers: {'Authorization': 'Basic key'}
Examples
GET request:
$http.get('url', { //same for post also
headers: {'Authorization': 'Basic key'}
});
Post Request:
$http.post("url", requestData, {
headers: { 'Authorization': 'Basic yourkey'}
}).success(function(responseData) {
//do stuff with response
});
Upvotes: 0
Reputation: 646
var config = {
method: 'POST',
url: 'https://somesite.com/',
headers: {
// key value pair of headers
'Authorization': 'Your auth key'
},
data: body of request
};
$http(config)
.success(function(){})
.error(function(){})
Upvotes: 2