-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (29 loc) · 882 Bytes
/
Copy pathapp.js
File metadata and controls
36 lines (29 loc) · 882 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
32
33
34
35
36
const lugar = require("./lugar/lugar.js");
const clima = require("./clima/clima.js");
const argv = require("yargs").options({
direccion: {
alias: "d",
desc: "Direccion de la ciudad para obtener el clima",
demand: true,
},
}).argv;
// argv.direccion
// Obtener Lugar con latitud y longitud
// lugar.getLugarLatLng(argv.direccion).then(console.log);
// Obtener clima
// clima
// .getClima(40.71, -74.01)
// .then(console.log)
// .catch((err) => {
// console.log(err);
// });
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);