-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgeocode.js
More file actions
33 lines (24 loc) · 789 Bytes
/
geocode.js
File metadata and controls
33 lines (24 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var googleMapsClient = require('@google/maps').createClient({
key: process.env.GOOGLE_API_KEY
});
// var globalAddress = '1080 folsome st san francisco';
function validateAddress(address) {
var getFormatted = new Promise(function(resolve, reject) {
googleMapsClient.geocode({
address: address
}, function(err, response) {
if (err) {
reject(new Error('Address is bogus'));
} else {
resolve(response.json.results[0].formatted_address);
}
})
})
return getFormatted
}
// validateAddress('1080 folsome st san francisco').then(function(result) {
// console.log(result);
// })
module.exports = {
validateAddress: validateAddress
}