Trying to use an external API.
$http({method: 'json', url: url })
.then(function(data){
console.log(data);
}, function(err, code){
console.log(err);
})
The error I get is:
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:3000' is therefore not allowed access. The response had HTTP status code 401.
I can't configure the API to accept from a diffrent domain. Instead I try to use jsonp
.
$http({method: 'jsonp', url: url })
If I check the network tab in chrome dev tools I can see a properly recived 200 OK response with the data.
But angular puts out: Unexpected token :
This is because angular expects "json callback". Is there anyway I can fix this from the client side?