1
I am trying to read with an Angularjs/Phonegap application an HTTPS address that gives me a JSON (https://gestormegaclube.com.br/api/app/v1/parceiros). I’m getting this mistake:
Xmlhttprequest cannot load https://gestormegaclube.com.br/api/app/v1/parceiros. Response to preflight request doesn’t pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://localhost:8000' is therefore not allowed access. The Response had HTTP status code 404.
angular.js:14700 Possibly unhandled rejection: {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, X-Requested-With","Access-Control-Allow-Credentials":true,"Accept":"application/json, text/plain, */*"},"url":"https://gestormegaclube.com.br/api/app/v1/parceiros"},"statusText":"","xhrStatus":"error"}
I don’t think this is server blocking because using Postman (https://www.getpostman.com/) it returns me the information, I’ve used several different header and nothing works.
.controller('MainController', function($scope, $http){
$http.get("https://gestormegaclube.com.br/api/app/v1/parceiros", {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, X-Requested-With',
'Access-Control-Allow-Credentials': true
}
}).then(function(response) {
$scope.data = response.data;
});
});
Maybe it’s because I’m on localhost, someone knows how to get around it?
That link didn’t work
– GeekSilva