Skip to content

Commit bdf8aab

Browse files
committed
One more try
1 parent ccd631f commit bdf8aab

1 file changed

Lines changed: 27 additions & 10 deletions

File tree

posters/index.html

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
<html>
2+
<head>
3+
<title>Posters</title>
4+
</head>
25
<body>
6+
<h1>Loading posters...</h1>
37
<script>
48
(async () => {
5-
const response = await fetch('https://api.github.com/repos/gofflab/gofflab.github.io/contents/posters/');
6-
const data = await response.json();
7-
let htmlString = '<ul>';
8-
9-
for (let file of data) {
10-
htmlString += `<li><a href="https://gofflab.github.io/${file.path}">${file.name}</a></li>`;Retry
11-
}
9+
try {
10+
const response = await fetch('https://api.github.com/repos/gofflab/gofflab.github.io/contents/posters');
11+
12+
if (!response.ok) {
13+
throw new Error(`API Error: ${response.status} ${response.statusText}`);
14+
}
15+
16+
const data = await response.json();
17+
let htmlString = '<ul>';
18+
19+
for (let file of data) {
20+
// Filter out the index.html file itself
21+
if (file.name !== 'index.html') {
22+
htmlString += `<li><a href="https://gofflab.github.io/${file.path}">${file.name}</a></li>`;
23+
}
24+
}
1225

13-
htmlString += '</ul>';
14-
document.getElementsByTagName('body')[0].innerHTML = htmlString;
26+
htmlString += '</ul>';
27+
document.getElementsByTagName('body')[0].innerHTML = htmlString;
28+
} catch (error) {
29+
document.getElementsByTagName('body')[0].innerHTML = `<p>Error: ${error.message}</p>`;
30+
console.error('Error fetching directory:', error);
31+
}
1532
})()
1633
</script>
17-
<body>
34+
</body>
1835
</html>

0 commit comments

Comments
 (0)