I set up a very simple class in TypeScript to access the "Place autocomplete" API from Google using Axios as HTTP client but the request failed and returns a CORS error.
import axios from 'axios'
export default class GoogleRequester {
  private apiKey: string = ''
  constructor (apiKey: string) {
    this.apiKey = apiKey
  }
  placesAutocomplete (query: string) {
    let requestString = `https://maps.googleapis.com/maps/api/place/queryautocomplete/json?key=${this.apiKey}&input=${encodeURIComponent(query)}`
    return axios.get(requestString)
  }
}
Failed to load https://maps.googleapis.com/maps/api/place/queryautocomplete/json?key=&input=fre: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
How to do it well ?
 
     
    