-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweather.js
46 lines (34 loc) · 939 Bytes
/
weather.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const request = require('request');
const yargs = require('yargs');
const geocode = require('./geocode/geocode.js');
const forecast = require('./forecast/forecast.js');
const argv = yargs.options({
a: {
demand: true,
string: true,
alias: 'address',
describe: 'coordinates to the provided address'
}
})
.argv;
geocode.geocodeAddress(argv.address, function(errorMessage, results){
if(errorMessage)
{
console.log(errorMessage);
}
else{
console.log(results.address);
forecast.getWeather(results.latitude, results.longitude, function(errorMessage, weatherResuts)
{
if(errorMessage)
{
console.log(errorMessage);
}
else
{
console.log(JSON.stringify(weatherResults, undefined, 3));
}
})
}
});
forecast.getWeather();