Skip to content

Instantly share code, notes, and snippets.

@kameshsampath
Last active February 23, 2018 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kameshsampath/efc3c3fe396b34af56ff93d44796675c to your computer and use it in GitHub Desktop.
Save kameshsampath/efc3c3fe396b34af56ff93d44796675c to your computer and use it in GitHub Desktop.
The snippet to show whats the wrong code looks like
'use strict';
const gmap = require('@google/maps');
function location(params) {
const latlng = JSON.parse(JSON.stringify(params.coords))
const gmapClient = gmap.createClient({
key: process.env.GOOGLE_MAPS_API_KEY
})
gmapClient.reverseGeocode({
"latlng": latlng,
"result_type": "postal_code"
},function(function(results, status){
if (status === 'OK'){
return {status: 'Err',location: response.json.results[0].formatted_address}
}else{
return {status: status,location: 'Unknown'}
}
})
return {status: status,location: 'Unknown'}
}
global.main = location;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment