-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsl.js
More file actions
28 lines (23 loc) · 784 Bytes
/
Copy pathsl.js
File metadata and controls
28 lines (23 loc) · 784 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
var uri = "https://cors-anywhere.herokuapp.com/http://api.sl.se/api2/realtimedeparturesV4.json?key=b0c3cced0bba45c58222712c148b6cf2&siteid=9633&timewindow=42";
const boi = document.getElementById('sl');
fetch(uri)
.then((resp)=>resp.json())
.then(function(data)
{
let tram = data.ResponseData.Trams;
boi.innerHTML += `<h1>TÄBY C TÅGINFO</h1>`;
return tram.map(function(tramobj)
{
boi.innerHTML += `${tramobj.LineNumber} mot `;
boi.innerHTML += ` ${tramobj.Destination} kommer om `;
boi.innerHTML += `${tramobj.DisplayTime}`;
if(tramobj.Deviations != null)
{
tramobj.Deviations.forEach(foo=>
{
boi.innerHTML += `<br>`;
})
}
else{boi.innerHTML += `<br>`}
})
})