-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (28 loc) · 910 Bytes
/
app.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
const lugar = require('./lugar/lugar');
const clima = require('./clima/clima');
const argv = require('yargs').options({
direccion: {
alias: 'd',
desc: 'Direccion de la ciudad para obtner el clima',
demand: true
}
}).argv;
// lugar.getLugarLatLng( argv.direccion )
// .then(console.log);
//
// console.log(argv.direccion);
// clima.getClima(40.750000, -74.000000 )
// .then(console.log)
// .catch(console.log);
const getInfo = async( direccion ) => {
try {
const coords = await lugar.getLugarLatLng( direccion );
const temp = await clima.getClima( coords.lat, coords.lng );
return `El clima de ${ coords.direccion } es de ${ temp }.`;
} catch (e) {
return `No se pudo determinar el clima de ${ direccion }`;
}
}
getInfo (argv.direccion)
.then(console.log)
.catch(console.log);