Created
October 6, 2019 13:40
-
-
Save jcreedcmu/0842b7a550b8758c48fa9397e6e86cb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const qs = require('querystring'); | |
const https = require('https'); | |
const query = { | |
key: fs.readFileSync('/home/jcreed/private/maps-api2', 'utf8').replace(/\n/g, ''), | |
input: "chipotle", | |
inputtype: "textquery", | |
fields: "formatted_address,name", | |
location: "40.7831,-73.9712", // manhattan | |
radius: 10000 | |
}; | |
const url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?" + qs.encode(query); | |
console.error(url); | |
https.get(url, (response) => { | |
let body = ''; | |
response.on('data', (chunk) => { | |
body += chunk; | |
}); | |
response.on('end', () => { | |
console.log(body); | |
}); | |
}).on('error', function(e) { | |
console.log("Got error: " + e.message); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment