Man I am really struggling getting the serverless ...
# prisma-whats-new
m
Man I am really struggling getting the serverless functions to work I was going to use them to geocode addresses I figured out the node version is 4.8.4 and I figured I should be able to use the
https.get
method to make the request but it just isn't working
Copy code
const https = require('https');
module.exports = function (event) {
  const GEOCODE_API = '<https://maps.googleapis.com/maps/api/geocode/json?>';
  const API_KEY     = 'key=<MYGOOGLEAPIKEY>';
  const STREET      = event.data.street;
  const CITY        = event.data.city;
  const STATE       = event.data.state;
  const ZIP         = event.data.zip;
  const ADDRESS_KEY = 'address=' + STREET + '%20' + CITY + '%2C%20' + STATE + '%20' + ZIP;
  const URL = GEOCODE_API + API_KEY + '&' + ADDRESS_KEY;
  https.get(URL, (res) => {
    console.log('statusCode:', res.statusCode);
    console.log('headers:', res.headers);

    res.on('data', (d) => {
      console.log(d);
    });

  }).on('error', (e) => {
    console.error(e);
  });
}
n
you need to wrap callbacks with new Promise((resolve, reject) => ...)
just use
fetch
instead (
isomorphic-fetch
)