Skip to content

Instantly share code, notes, and snippets.

@bmorelli25
Created June 20, 2017 12:41
Show Gist options
  • Save bmorelli25/8b03c50b913796a42a10a8996971ab2c to your computer and use it in GitHub Desktop.
Save bmorelli25/8b03c50b913796a42a10a8996971ab2c to your computer and use it in GitHub Desktop.
node.js weather app
const request = require('request');
const argv = require('yargs').argv;
let apiKey = '*****************************';
let city = argv.c || '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