Skip to content

Instantly share code, notes, and snippets.

@pyadav
Created August 9, 2015 08:22
Show Gist options
  • Save pyadav/883573f98ed45496c089 to your computer and use it in GitHub Desktop.
Save pyadav/883573f98ed45496c089 to your computer and use it in GitHub Desktop.
async function func () {
const url = 'https://maps.googleapis.com/maps/api/geocode/json?address=94043&sensor=false';
const { results: [ result ] } = await fetch(url).then((response) => response.json());
return JSON.stringify(result, null, 2);
}
func().then(console.log.bind(console));
/*
{
"address_components": [
{
"long_name": "94043",
"short_name": "94043",
"types": [
"postal_code"
]
},
{
"long_name": "Mountain View",
"short_name": "Mountain View",
"types": [
"locality",
"political"
]
},
{
"long_name": "California",
"short_name": "CA",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "United States",
"short_name": "US",
"types": [
"country",
"political"
]
}
],
"formatted_address": "Mountain View, CA 94043, USA",
"geometry": {
"bounds": {
"northeast": {
"lat": 37.4640869,
"lng": -122.0359899
},
"southwest": {
"lat": 37.3857439,
"lng": -122.10842
}
},
"location": {
"lat": 37.428434,
"lng": -122.0723816
},
"location_type": "APPROXIMATE",
"viewport": {
"northeast": {
"lat": 37.4640869,
"lng": -122.0359899
},
"southwest": {
"lat": 37.3857439,
"lng": -122.10842
}
}
},
"place_id": "ChIJoQmen1G3j4ARbhoe7nVBEoQ",
"types": [
"postal_code"
]
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment