-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (29 loc) · 954 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
const lugar = require('./lugar/lugar');
const clima = require('./clima/clima');
const argv = require('yargs').options({
direccion: {
descripcion: 'Direccion de la ciudad para obtener el clima',
alias: 'd',
demand: true
}
}).argv
// lugar.getLugarLatLong(argv.direccion).then(res => {
// console.log(res);
// }).catch(err => {
// console.log(err);
// })
// clima.getClima(14.630000, -90.610001)
// .then(res => console.log(res))
// .catch(err => console.log(err))
const getInfo = async (direccion) => {
try {
const coords = await lugar.getLugarLatLong(direccion);
const temp = await clima.getClima(coords.lat, coords.lng);
return `El clima de ${coords.direccion} es ${temp} grados`
} catch (error) {
return `No se pudo determinar el clima de ${direccion}`
}
}
getInfo(argv.direccion)
.then(res => console.log(res))
.catch(err => console.log(err))