I am trying to make an api call (Google Places API). However I keep getting the following error
Access to XMLHttpRequest at 'https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Seoul&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry&key=--snip--' from origin 'http://localhost:8100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
using the following code:
getRemoteData() {
this.http
.get(
"https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Seoul&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry&key=--snip--"
)
.map(res => res)
.subscribe(data => {
console.log(data);
});
}
However if I replace the url with https://www.reddit.com/r/gifs/top/.json?limit=105sort=hot
it works fine. Why is that so? How can I fix it?