Skip to content

Instantly share code, notes, and snippets.

@kevinl95
Last active November 25, 2018 21:38
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 kevinl95/68eb43402e379a43039612b04c99d571 to your computer and use it in GitHub Desktop.
Save kevinl95/68eb43402e379a43039612b04c99d571 to your computer and use it in GitHub Desktop.
exports.handler = function( event, context ) {
var http = require( 'http' );
var url = 'http://api.openweathermap.org/data/2.5/weather?zip=<YOURZIPCODEHERE>,us&units=imperial&APPID=<YOURAPIKEYHERE>';
http.get( url, function( response ) {
var data = '';
response.on( 'data', function( x ) { data += x; } );
response.on( 'end', function() {
var json = JSON.parse( data );
var temp = json.main.temp;
var wind_speed = json.wind.speed;
var wind_chill = 35.74 + 0.6215*temp - 35.75*Math.pow(wind_speed, 0.16) + 0.4275*temp*Math.pow(wind_speed, 0.16);
var chill_rounded = Math.round( wind_chill * 10 ) / 10;
var text = 'Outside with wind chill the temperature feels like ';
text+=chill_rounded+" degrees fahrenheit.";
output( text, context );
} );
} );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment