-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
58 lines (46 loc) · 1.22 KB
/
app.js
File metadata and controls
58 lines (46 loc) · 1.22 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
const {
argv
} = require('./config/yargs')
const {
getPlace,
sendGet
} = require('./logica/get-info-place')
const {
getTemperatureByGeoCoordinates
} = require('./logica/get-temp-place')
/* sendGet(argv.direccion)
.then(res => {
console.log(res)
})
.catch()
*/
async function getCoordWeather(direccion) {
try {
let coord_place = await getPlace(direccion)
let temp_place = await getTemperatureByGeoCoordinates(coord_place.longitud, coord_place.latitud)
return {
place_name: coord_place.place_name,
place_lat: coord_place.latitud,
place_longi: coord_place.longitud,
weather: temp_place.weather.main,
temperature: temp_place.temperatures.temp
}
} catch (error) {
return error
}
/* await getPlace(argv.direccion)
.then(res=>{
await getTemperatureByGeoCoordinates(res.longitud, res.latitud, 'metric')
}) */
}
getCoordWeather(argv.direccion)
.then(res => {
console.log('-----------------------------------------------------')
console.log(`El tiempo de ${res.place_name} es: ${res.weather}`)
console.log(`La latitud es ${res.place_lat}`)
console.log(`La longitud es ${res.place_longi}`)
console.log(`Y su temperatura de ${res.temperature} grados`)
})
.catch(err => {
console.log(err)
})