Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async (placeId: string) => {
try {
const response = await axios.get(
`https://maps.googleapis.com/maps/api/place/details/json?placeid=${placeId}&fields=name,opening_hours/weekday_text,formatted_phone_number,vicinity,website,reviews,url,type&key=${
Config.GOOGLE_PLACES_API_KEY
}`,
);
console.log(response);
return response;
} catch (error) {
console.log(error);
return null;
}
};
export default async (latitude: string, longitude: string, pageToken: string) => {
try {
const urlFirst = `https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${latitude},${longitude}&radius=1500&rankBy=distance&type=bar&key=${
Config.GOOGLE_PLACES_API_KEY
}`;
const urlNext = `https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${latitude},${longitude}&radius=1500&rankBy=distance&type=bar&key=${
Config.GOOGLE_PLACES_API_KEY
}&pagetoken=${pageToken}`;
const url = pageToken === '' ? urlFirst : urlNext;
const response = await axios.get(url);
console.log(response);
return response;
} catch (error) {
console.log(error);
return null;
}
};
searchBars = async () => {
try {
const {
bars, latitude, longitude, pageToken,
} = this.state;
const urlFirst = `https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${latitude},${longitude}&radius=1500&type=bar&key=${
Config.GOOGLE_PLACES_API_KEY
}`;
const urlNext = `https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${latitude},${longitude}&radius=1500&type=bar&key=${
Config.GOOGLE_PLACES_API_KEY
}&pagetoken=${pageToken}`;
const url = pageToken === '' ? urlFirst : urlNext;
const response = await axios.get(url);
const arrayData = [...bars, ...response.data.results];
this.setState({
bars: pageToken === '' ? response.data.results : arrayData,
refreshing: false,
pageToken: response.data.next_page_token,
});
console.log(response);
} catch (error) {
{return '';}}
GooglePlacesSearchQuery={{rankby: 'distance',}}
GoogleReverseGeocodingQuery={{}}
minLength={2}
nearbyPlacesAPI='GooglePlacesSearch'
onPress={this.selectLocation}
placeholder='Your city'
predefinedPlaces={[]}
query={{
key: Config.GOOGLE_PLACES_API_KEY,
language: 'en',
types: '(cities)',
}}
styles={autocompleteStyles}>
title={{ title: 'Create Assembly', tintColor: 'white' }}
tintColor={Colors.brandPrimary}
leftButton={}
/>
{ return ''; }}
query={{
key: Config.GOOGLE_PLACES_API_KEY,
language: 'en',
types: '(cities)',
}}
currentLocation={false}
currentLocationLabel="Current location"
nearbyPlacesAPI='GooglePlacesSearch'
GoogleReverseGeocodingQuery={{}}
GooglePlacesSearchQuery={{ rankby: 'distance',}}
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']}
predefinedPlaces={[]}
/>