Skip to content

Instantly share code, notes, and snippets.

@Israel025
Last active April 17, 2019 18:38
Show Gist options
  • Save Israel025/07a41756c981c5f3e9eda5dfc093c84d to your computer and use it in GitHub Desktop.
Save Israel025/07a41756c981c5f3e9eda5dfc093c84d to your computer and use it in GitHub Desktop.
weahter-cli application
const ora = require('ora');
const getWeather = require('../utils/weather');
const getLocation = require('../utils/location');
module.exports = async (args) => {
const spinner = ora().start();
try{
const location = args.location || args.l || await getLocation();
const weather = await getWeather(location);
spinner.stop();
// console.log(weather);
console.log(`The condition for Tomorrow ${weather.list[1].dt_txt} in ${weather.city.name}, ${weather.city.country} is:`);
console.log(`\t${weather.list[1].main.temp}F`);
}catch(error){
console.error(error);
}
}
const axios = require('axios');
module.exports = async (location) => {
let result;
try {
result = await axios({
method: 'get',
url: `http://api.openweathermap.org/data/2.5/forecast?q=${location.city},${location.country_code}&APPID=6ea8e158302271fd6d95f5cfbf3a60e8&cnt=2`,
})
} catch (error) {
console.error(error);
}
return result.data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment