Answer the question
In order to leave comments, you need to log in
Why is it throwing CORS error google api autocomplete?
Such situation. I want to get a list of cities where value = "Mo" for example. Code below. In the first case, it gives an error: Uncaught SyntaxError: Unexpected token :
const url = `https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${value}&types=(cities)&key=AIzaSyA5fYKOUOtx02o9l4TxzUiAvNslkhT8Nwc`,
type = "GET",
dataType = 'jsonp',
cache = false;
$.ajax({
url, type, dataType, cache,
success: function(response){
alert(response);
}
});
<script src="https://apis.google.com/js/api.js" type="text/javascript"></script>
<script type="text/javascript">
gapi.load('auth2', init);
</script>
Answer the question
In order to leave comments, you need to log in
Is your init initialized somewhere? If so, why pass undefined there?
function init() {
gapi.client.init({
'apiKey': '...',
'discoveryDocs': [...],
...
}).then(...)
};
function loadClient() {
gapi.load('auth2', init);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question