Skip to content

Instantly share code, notes, and snippets.

@dlbnco
Created September 24, 2018 23:45
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 dlbnco/335faca3cd7e7843b65514f3a2f5139b to your computer and use it in GitHub Desktop.
Save dlbnco/335faca3cd7e7843b65514f3a2f5139b to your computer and use it in GitHub Desktop.
const fetch = require('node-fetch')
const GOOGLE_PLACES_API_KEY = 'your-key';
module.exports = function (event) {
const { id } = event.data
return fetch(fetchGooglePlace(id))
.then(res => res.json())
.then(payload => {
console.log(payload)
return {
data: {
payload
}
}
})
}
function fetchGooglePlace(id) {
return `https://maps.googleapis.com/maps/api/place/details/json?placeid=${id}&key=${GOOGLE_PLACES_API_KEY}`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment