question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google API CORS ISSUE

See original GitHub issue

Hello 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

2reactions
ImAbhishekTomarcommented, May 25, 2018

con you please share sample code ?

0reactions
ionitron-bot[bot]commented, Nov 29, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending a details request to Google Places API - (CORS error)
React - development server,"cors" issues using https url to retrieve data from api. I had the exact same issue using the google api...
Read more >
CORS error when making place request · Issue #172 - GitHub
Trying to make a simple place call to google client to fetch place details on client side and getting CORS error.
Read more >
Google Maps API Common Errors & Solutions | by Raja Tamil
CORS Error. When you make an HTTP Request to the Google Maps API service from the Client, you'll probably get the CORS error...
Read more >
Cross-origin resource sharing (CORS) | Cloud Storage
XML API endpoints accept CORS requests based on the CORS configuration on the target bucket. The authenticated browser download endpoint storage.cloud.google.
Read more >
Google Place API blocked by CORS policy - Support
What I'm trying to do: Access Google Place API from my Netlify app (Create-react-app) My problem: I'm getting CORS error: (index):1 Access ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found