Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
delijn821 authored Oct 13, 2024
1 parent f49edd4 commit 18724ad
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions versie3rt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>De Lijn Realtime Data</title>
<script>
async function fetchRealtimeData() {
try {
const response = await fetch("https://api.delijn.be/gtfs/v3/realtime", {
method: "GET",
headers: {
"Cache-Control": "no-cache",
"Ocp-Apim-Subscription-Key": "24668cab5bac4d27bfafe5013a8fab3b"
}
});

if (!response.ok) {
throw new Error(`Error: ${response.status}`);
}

const data = await response.json();
saveJsonToFile(data);
} catch (error) {
console.error('Failed to fetch data', error);
}
}

function saveJsonToFile(data) {
const json = JSON.stringify(data, null, 2);
const blob = new Blob([json], { type: "application/json" });
const url = URL.createObjectURL(blob);

const a = document.createElement('a');
a.href = url;
a.download = 'realtime_data.json';
a.click();

URL.revokeObjectURL(url);
}
</script>
</head>
<body>
<h1>De Lijn Realtime Data</h1>
<button onclick="fetchRealtimeData()">Download JSON</button>
</body>
</html>

0 comments on commit 18724ad

Please sign in to comment.