nchaulet / node-geocoder

nodejs geocoding library

Home Page:http://nchaulet.github.io/node-geocoder/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR Failed to execute 'fetch' on 'Window': Illegal invocation

leogetzit opened this issue · comments

I have Google Api key.
This code works gives ERROR Failed to execute 'fetch' on 'Window': Illegal invocation
This is in React
Any help?
const options={ language:"en", region:"MY", provider:"google", apiKey: Firebaseconfig.apiKey }; const geocoder = NodeGeocoder(options); console.log(geocoder); const [data, setData] = useState(null); const { Geolocation } = Plugins; useEffect(()=>{ if(data===null) Geolocation.getCurrentPosition() .then(position=>{ console.log(position.coords); addressObject.geo.latitude = position.coords.latitude; addressObject.geo.longitude = position.coords.longitude; geocoder.reverse({lat:position.coords.latitude, lon:position.coords.longitude}) .then(address=>{ console.log("FOUND ADDRESS", address); addressObject.address=address[0].formattedAddress; addressObject.plusCode = address["raw"].plus_code.global_code; setData(addressObject); }) .catch(err=>{ console.log("ERROR",err.message); }) }); // eslint-disable-next-line react-hooks/exhaustive-deps },[]);

Hi @leogetzit, I am sorry but this module is not mean to run in the browser, it's mean to support nodejs only.