Created
June 19, 2017 20:06
-
-
Save bmorelli25/baa7cce6569f209e0dfbc4b1dc355f56 to your computer and use it in GitHub Desktop.
Node.js Weather App - part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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