-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (23 loc) · 838 Bytes
/
app.js
File metadata and controls
31 lines (23 loc) · 838 Bytes
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
const lugar = require('./lugar/lugar');
const clima = require('./clima/clima');
const argv = require('yargs').options({
direccion: {
alias: 'd',
desc: 'Direccion de la ciudad para obtener el clima',
demand: true
}
}).argv;
// lugar.getLugarLatLng(argv.direccion)
// .then(console.log);
// clima.getClima(35, 139).then(console.log).catch(console.log);
const getInfo = async(direccion) => {
try {
const getLugar = await lugar.getLugarLatLng(direccion);
const getClima = await clima.getClima(getLugar.lat, getLugar.lng);
return `El clima de ${ getLugar.direccion } es de ${getClima}.`
} catch (error) {
return `No se pudo determinar el clima de ${ direccion }`
}
// console.log(clima);
}
getInfo(argv.direccion).then(console.log).catch(console.log);