-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
40 lines (37 loc) · 1.4 KB
/
index.html
File metadata and controls
40 lines (37 loc) · 1.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Test</title>
</head>
<body>
<h1>API Endpoint Test</h1>
<button onclick="fetchInfo()">Fetch Info</button>
<button onclick="fetchArray()">Fetch Array</button>
<div id="output"></div>
<script>
const baseURL = "https://dsa-07qz.onrender.com";
async function fetchInfo() {
try {
const response = await fetch(`${baseURL}/info`);
const data = await response.json();
document.getElementById('output').innerHTML = `<pre>${JSON.stringify(data, null, 2)}</pre>`;
} catch (error) {
console.error('Error fetching /info:', error);
document.getElementById('output').innerText = "Error fetching /info.";
}
}
async function fetchArray() {
try {
const response = await fetch(`${baseURL}/array`);
const data = await response.json();
document.getElementById('output').innerHTML = `<pre>${JSON.stringify(data, null, 2)}</pre>`;
} catch (error) {
console.error('Error fetching /array:', error);
document.getElementById('output').innerText = "Error fetching /array.";
}
}
</script>
</body>
</html>