I have an API to get the data I have to put Authorization in header but it didn't work. Here is the image in postman
https://drive.google.com/open?id=18CY4uBc83u9AcN9Uu2SFXMjPgc4FPBzU
I have applied this question answer AngularJS Adding a header to the $http.get But it didn't work.
HTML:-
<button type="button" class="btn btn-primary btn-xs" ng-click="getApiData()">
GET DATA
</button>
JS:-
$scope.getApiData = function(){
$http({
method : 'GET',
url : 'http://api.getlokalapp.com/posts/7678/?format=json',
headers : {
'Content-Type' : 'application/json',
'Authorization' : '5ae5f64653ce85803b44b7b6f4d216c2dae02251'
}
})
.then(function(response){
console.log(response);
});
}
I want the output is response as it is shown in postman request but I am unable to get it please help me to get the data from the API.
Error message which I am getting is-
Access to XMLHttpRequest at 'http://api.getlokalapp.com/posts/7678/?format=json' from origin 'http://localhost:9000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
But I have integrated other APIs and there I didn't get any error.