Skip to content

Instantly share code, notes, and snippets.

@bmorelli25
Created June 19, 2017 20:06
Show Gist options
  • Save bmorelli25/baa7cce6569f209e0dfbc4b1dc355f56 to your computer and use it in GitHub Desktop.
Save bmorelli25/baa7cce6569f209e0dfbc4b1dc355f56 to your computer and use it in GitHub Desktop.
Node.js Weather App - part 2
let request = require('request');
let apiKey = '***********************************';
let city = 'portland';
let url = `http://api.openweathermap.org/data/2.5/weather?q=${city}&units=imperial&appid=${apiKey}`
request(url, function (err, response, body) {
if(err){
console.log('error:', error);
} else {
let weather = JSON.parse(body)
let message = `It's ${weather.main.temp} degrees in ${weather.name}!`;
console.log(message);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment