1
Good afternoon, I am trying to make a client that indexes the information of various webservices (on bitcoin quotes from various brokers) but when trying to access the webservice the values imported from json are not displayed, and pressing F12 on Chrome returns the following error message:
Xmlhttprequest cannot load https://api.blinktrade.com/api/v1/BRL/ticker?crypto_currency=BTC. No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://localhost' is therefore not allowed access.
have already given a search on the error, the same tbm occurs on my remote test server (Hostinger), I know the error occurs because the server does not return the header "Access-Control-Allow-Origin = *" however are many different third party servers that I will fetch and all return me this same error...
follows the code used to access WS: (service)
app.factory('foxbit', ['$http',
function($http){
return $http.get('https://api.blinktrade.com/api/v1/BRL/ticker?crypto_currency=BTC')
.success(function(data) {
return data;
})
.error(function(err) {
return err;
});
}]);
Controller:
app.controller('MainController', ['$scope', 'foxbit', function($scope, foxbit) {
foxbit.success(function(data) {
$scope.cotacaofox = data;
});
}]);
So if the ninjas here can point me to a way around this mistake,.
Thank you.
Have you tried creating a virtual host to see if you can get around the problem? Tip: Don’t leave succes and error in Factory. You should treat this in the controller. And instead of using these functions to handle the return, use 'then'. The two above seem to be 'deprecated'.
– Marcos Kubis
The problem of the virtual host is that I will put the page on a remote server that does not have access to this customization on the remote server, and as for the Success and the error, I put only pq is easier, but I intend to put it into production..
– Dennis