-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·31 lines (26 loc) · 863 Bytes
/
index.js
File metadata and controls
executable file
·31 lines (26 loc) · 863 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 axios = require("axios");
const URL =
"http://api.openweathermap.org/data/2.5/weather?q=Orlando&units=imperial&APPID=ae45492188698ff6c35c430a814ed78b";
axios
.get(URL)
.then(res => {
const temp = Math.round(res.data.main.temp);
const weather = res.data.weather[0];
const time =
new Date().getHours() >= 18 || new Date().getHours() <= 6 ? "" : "";
let weatherIcon;
if (
(weather.id >= 500 && weather.id <= 531) ||
(weather.id >= 200 && weather.id <= 232) ||
(weather.id >= 300 && weather.id <= 321)
)
weatherIcon = "";
else if (weather.id >= 803 && weather.id <= 804) weatherIcon = "";
else if (weather.id >= 800 && weather.id <= 802) {
weatherIcon = time;
}
console.log(`${weatherIcon} ${temp}°`);
})
.catch(err => {
console.log(" --°");
});