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
2 Answers
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(){})
1 Comment
user3012606
m getting error when seeing in the console Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at 82.223.29.24/SIUKService/Api/Login/loginUser. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
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
});
1 Comment
Manwal
@user3012606 added post request example