-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
53 lines (35 loc) · 1.01 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
let minimist = require('minimist')
let cTable = require('console.table')
let {conf} = require ('./conf/conf')
let {Weather} = require('./controller/wether-controller')
let argv = minimist(process.argv.slice(2))
let {url,appid} = conf
let {city, units} = argv
async function main() {
let weather = new Weather(url, appid)
try {
let data = await weather.get_wather(city, units)
// console.log(data);
let {temp, temp_min, temp_max, humidity} = data.data.main
let {country} = data.data.sys
let temperature = {
temp,
temp_min,
temp_max,
humidity,
country
}
const table = cTable.getTable([
temperature
])
console.log(table);
} catch (error) {
let {response:{data}} = error
//console.log(data);
const table2 = cTable.getTable([
data
])
console.log(table2);
}
}
main()