Comments (9)
@stephenmcd are you willing to accept a pull request to make compatible with react-native?
it would make this package https://github.com/FaridSafi/react-native-google-places-autocomplete easier to maintain
from google-maps-services-js.
One note on this - using the web services from a mobile device is highly discouraged, as it exposes your unrestricted API key to malicious users.
from google-maps-services-js.
@stephenmcd Indeed, it is not a perfect solution. I am using react-native-config to manage keys the best I can, but they still get bundled with the app and could get reverse engineered out I suppose.
Is there a better way to call these APIs from a React Native app?
from google-maps-services-js.
Best approach is a server-side component that acts as a proxy between devices and third-party APIs such as maps.
from google-maps-services-js.
I'll close this for now - we could probably get it working by swapping out https
with fetch
, but doing so would encourage insecure practices as mentioned above. You can always fork the library and patch it if you'd like to ignore this.
from google-maps-services-js.
How would you address the issues I mentioned?
from google-maps-services-js.
I think it is a good idea to move to fetch
instead of https
making it available in react-native could be a good thing for simple demos
from google-maps-services-js.
Possible workaround is to use this library only for types, but send requests by anything our environment likes.
This is how I use it in Nitro on edge worker:
import { defaultUrl, PlaceAutocompleteRequest, PlaceAutocompleteResponseData } from '@googlemaps/google-maps-services-js/dist/places/autocomplete'
const { googleMapsApiKey } = useRuntimeConfig()
export default defineEventHandler<{ query: {
input: string
language: string
sessionToken: string
} }>(async (event) => {
const { input, language, sessionToken } = getQuery(event)
try {
const data = await $fetch<PlaceAutocompleteResponseData>(defaultUrl, {
query: {
input,
language,
key: googleMapsApiKey,
sessiontoken: sessionToken,
} as PlaceAutocompleteRequest['params']
})
if (data.status !== 'OK' && data.status !== 'ZERO_RESULTS')
throw createError({ statusCode: 400, statusMessage: 'Bad Request' })
return data
}
catch (err) {
console.log(err)
throw createError({ statusCode: 500, statusMessage: 'Internal Server Error' })
}
})
from google-maps-services-js.
Btw, on all frontends we need to use proper API key - read only access. It does not matter what client library we use.
from google-maps-services-js.
Related Issues (20)
- Address autocomplete ApiNotActivatedMapError HOT 1
- StreetViewService.getPanorama implementation HOT 2
- Cross-site Request Forgery (CSRF) issue with Axios, replace with fetch? HOT 7
- Add new Pollen APIs HOT 1
- Google RouteMatrix needed. HOT 2
- Dependency url-signature using a version of crypto-js with critical vulnerability HOT 6
- New APIs: Address Validation, Datasets, Places, Routes HOT 4
- Autocomplete prediction type fields should be optional HOT 1
- Rename primary branch to main
- reviews_sort & reviews_no_translations fields are not included in place deatils params HOT 2
- "Place Details (New)" API calls HOT 4
- Directions: Missing type "google.maps.DirectionsStatus" in "google.maps.DirectionsResult" OS:W11 Pro HOT 1
- Cannot find module 'core-js/modules/es.string.replace.js' HOT 5
- Add support for Address Descriptors to Geocoding
- Cross-Origin-Resource-Policy missing from response header of khms0.googleapis.com and khms1.googleapis.com HOT 1
- Error: Cannot find module 'core-js/modules/es.string.replace.js' HOT 15
- Places.placeAutocomplete can't filter by country HOT 1
- 127.0.0.1:22259/main/0/storage/emulated/11/Download/Takeout/Historial de ubicaciones (Rutas)/Timeline Edits.GeoJSON.gpx.html
- Error: Type '"origin" | undefined' is not assignable to type '"origin"' during Build. HOT 7
- TypeScript error in Request interfaces HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-maps-services-js.