I'm trying to do a simple get
request in Angular to a certain API, but I get the following:
XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key=MY_KEY. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://my-site.herokuapp.com' is therefore not allowed access.
I have tried many different APIs just to test if maybe it's a setting that needs enabled on my target API or if it's just something in general with any ol' API I try to access. I got this error with all of them, so at this point it's GOTTA be something I'm doing wrong.
Also to note, I'm pushing to heroku so it's up and running on a web server, not local host.
Here's my angular code below:
$http.get("https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key=MY_KEY")
.then(function(response) {
vm.output = response.data;
});
I've opened about a thousand browser tabs searching for info on this, and many say "You don't. The server you are making the request to has to implement CORS to grant JavaScript from your website access." or something like that. But I'm trying Google and obviously they should allow cross-site requests, so it's gotta be something I'm doing wrong. Thanks for any help.