untitled notebook

node v6.17.1
version: 1.0.0
endpointsharetweet
const url = require('url'); const got = require("got"); module.exports.endpoint = async function(req, res) { const { zipCode } = url.parse(req.url, true).query const URL = `http://api.openweathermap.org/data/2.5/weather?zip=${zipCode}&appid=${process.env.OPEN_WEATHER_APP_KEY}`; const data = (await got(URL)).body; res.end(data); }
await module.exports.endpoint({url: "http://test.com/?zipCode=94117"}, {end: console.log}) // url.parse("http://test.com/?zipCode=94117", true).query
Loading…

no comments

    sign in to comment