-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.html
More file actions
30 lines (28 loc) · 928 Bytes
/
data.html
File metadata and controls
30 lines (28 loc) · 928 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display JSON Data</title>
</head>
<body>
<h1>JSON Data</h1>
<pre id="json-output"></pre>
<script>
fetch('data.json') // Update this path if needed
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
document.getElementById('json-output').textContent = JSON.stringify(data, null, 2);
document.body.insertAdjacentHTML('beforeend', `<h2>${data.message}</h2>`);
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
</script>
</body>
</html>