Skip to content

Commit a0fe405

Browse files
authored
Update Wiki.html
1 parent 6bcdc39 commit a0fe405

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

Wiki/Wiki.html

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,28 @@
88
const apiUrl = 'https://api.jsonbin.io/v3/b/67c73db1e41b4d34e4a0bfb1/latest';
99

1010
async function fetchPages() {
11-
const response = await fetch(apiUrl);
12-
const data = await response.json();
13-
14-
console.log('Fetched data:', data); // Log the response to check its structure
15-
16-
// Check if data has a record property or handle the structure appropriately
17-
const pages = data.record || []; // Adjust based on actual response structure
18-
renderPages(pages);
11+
try {
12+
const response = await fetch(apiUrl);
13+
14+
// Check if the response is OK
15+
if (!response.ok) {
16+
console.error("Failed to fetch data", response.statusText);
17+
return;
18+
}
19+
20+
const data = await response.json();
21+
console.log('Fetched data:', data); // Log the entire data object
22+
23+
// Assuming pages are located directly in the response (adjust as needed)
24+
const pages = data.record || []; // If the pages are in a 'record' property, adjust accordingly
25+
if (Array.isArray(pages)) {
26+
renderPages(pages);
27+
} else {
28+
console.error("Pages data is not an array:", pages);
29+
}
30+
} catch (error) {
31+
console.error("Error fetching pages:", error);
32+
}
1933
}
2034

2135
async function createPage() {
@@ -57,6 +71,10 @@
5771
const pagesDiv = document.getElementById('pages');
5872
pagesDiv.innerHTML = '';
5973

74+
if (pages.length === 0) {
75+
pagesDiv.innerHTML = '<p>No wikis found.</p>';
76+
}
77+
6078
pages.forEach(page => {
6179
pagesDiv.innerHTML += `
6280
<div class="card">

0 commit comments

Comments
 (0)