-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweather-example.html
More file actions
54 lines (45 loc) · 1.18 KB
/
weather-example.html
File metadata and controls
54 lines (45 loc) · 1.18 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Weather Practice</title>
</head>
<body>
<h1>Exercise to Practice Open Weather Map</h1>
<script type="text/javascript" src="./js/keys.js"></script>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script>
"use strict";
$.get('https://api.openweathermap.org/data/2.5/forecast', {
lat: 29.4252,
lon: -98.4916,
appid: keys.openWeatherAPI,
units: 'metric'
}).done(function(data) {
// can be used to get forecast conditions at current time in increments of 24 hours
for (let i = 0; i < data.list.length; i += 8) {
console.log(data.list[i]);
}
}).fail(function(jqXhr, status, error) {
console.log(jqXhr);
console.log(status);
console.log(error);
});
$.get('https://openweathermap.org/weather-conditions',
{
lat: 29.4252,
lon: -98.4916,
appid: keys.openWeatherAPI,
units: 'metric'
}).done(function(data)
{
for (let i = 0; i < data.list.length; i += 8) {
console.log(data.city);
}
})
</script>
</body>
</html>