-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (40 loc) · 1.33 KB
/
script.js
File metadata and controls
47 lines (40 loc) · 1.33 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
41
42
43
44
45
46
47
async function fetchGitHubIssues() {
const repoOwner = "s0ooo0k";
const repoName = "TIL";
const url = `https://api.github.com/repos/${repoOwner}/${repoName}/issues`;
try {
const response = await fetch(url, {
headers: {
Accept: "application/vnd.github.v3+json",
},
});
if (!response.ok) {
throw new Error("Failed to fetch issues");
}
const issues = await response.json();
const issueContainer = document.getElementById("issues-container");
issues.forEach((issue) => {
const issueCard = document.createElement("div");
issueCard.classList.add("card", "mb-3");
issueCard.innerHTML = `
<div class="card-body">
<h5 class="card-title">
<a href="issue.html?issueId=${issue.number}" class="text-decoration-none">
📝 ${issue.title}
</a>
</h5>
</div>
`;
issueContainer.appendChild(issueCard);
});
} catch (error) {
console.error("Error fetching issues:", error);
const issueContainer = document.getElementById("issues-container");
issueContainer.innerHTML = `
<div class="alert alert-danger" role="alert">
Failed to fetch issues. Please try again later.
</div>
`;
}
}
document.addEventListener("DOMContentLoaded", fetchGitHubIssues);