Skip to content

Instantly share code, notes, and snippets.

@kameshsampath
Created 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/efcf46fdf190befe83e6f3ffc9266a40 to your computer and use it in GitHub Desktop.
Save kameshsampath/efcf46fdf190befe83e6f3ffc9266a40 to your computer and use it in GitHub Desktop.
This you should not do
'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
})
return new Promise(function (resolve, reject) {
gmapClient.reverseGeocode({
"latlng": latlng,
"result_type": "postal_code"
}, function (results, status) {
let respStatus = response.json.status
if (respStatus === 'OK') {
resolve({ status: respStatus, location: response.json.results[0].formatted_address })
} else {
reject({ status: respStatus, location: "" })
}
})
});
}
global.main = location;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment