0

I'm getting a CORS error when making a GET request to Google Places API. I kinda know what CORS is but I don't understand how am I supposed to avoid getting this error. Shouldn't the API's back end be the one who deals with this problem?

The code which causes the error:

axios.get('https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=%2B61293744000&inputtype=phonenumber&fields=place_id&key=')
    .then(response => {
        console.log(response)
    }).catch((error) => console.log(error));
Onyx
  • 5,186
  • 8
  • 39
  • 86
  • Maybe you need to do JSONP request instead? – Justinas Jan 17 '19 at 13:57
  • "Shouldn't the API's back end be the one who deals with this problem?" — Yes. Google clearly do not intend that that API be accessed via browser-side JavaScript. You might want to consult their documentation to see if they provide a similar API for browser-side JS. – Quentin Jan 17 '19 at 14:08

0 Answers0