Ad

Using API Google Places Details Error Allow Origin Cors React Project

I'm trying to use the Google Place API to get details of Places by their Id I'm using the service provided here https://developers.google.com/places/web-service/details

I'm developing on ReactJs

follows error image:

embedded image

I've seen around here that for these Allow Origin cases you should use Maps JavaScript API -->https://developers.google.com/maps/documentation/javascript/places#place_details

However what is the best way to get a google.maps reference in a REACTJS project?

Ad

Answer

I would recommend to react-google-maps which is component based. it's community is huge. Here is the working example of places API in react-google-maps make sure you have an API key. https://codesandbox.io/s/qqzm67ykmq

You need to get an API key first form here. Here are steps below for API key:

  • Create a project
  • Generate a API key
  • Enable places API and Maps Javascript API
  • Restrict your API key with these APIs
Ad
source: stackoverflow.com
Ad