Google API CORS ISSUE
See original GitHub issueHello Team,
I am trying to use Google Place Search REST JSON api, but its showing CORS error.
API URL : https://maps.googleapis.com/maps/api/place/textsearch/json?query=123+main+street&key=YOUR_API_KEY API Documentation url : https://developers.google.com/places/web-service/search
ERROR
Failed to load https://maps.googleapis.com/maps/api/place/textsearch/json?query=Mini+Mart+CITY+PLAZA+Gaur+City+1&key=mykey: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access.
Code Provider
getPlaceData(){
return new Promise(resolve => {
this.http.get(this.url).subscribe(data => {
resolve(data);
}, err => {
console.log(err);
});
});
}
Code Provider Use
ionViewDidLoad(){
//this.searchProvider.searchPlace().subscribe(res=> console.log(res));
this.searchProvider.getPlaceData()
.then(data => {
this.odata=data;
console.log(data);
});
}
Ionic Framework: 3.9.2 Ionic App Scripts: 3.1.9 Angular Core: 5.2.10 Angular Compiler CLI: 5.2.10 Node: 8.9.3 OS Platform: Windows 10 Navigator Platform: Win32 User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6
con you please share sample code ?
Issue moved to: https://github.com/ionic-team/ionic-v3/issues/417