-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (23 loc) · 757 Bytes
/
script.js
File metadata and controls
26 lines (23 loc) · 757 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
const username = "bvvnmanikanta";
const repo = "Frontend-Projects";
fetch(`https://api.github.com/repos/${username}/${repo}/contents`)
.then(response => response.json())
.then(data => {
const fileList = document.getElementById("file-list");
const ul = document.createElement("ul");
data.forEach(item => {
if (item.type === "dir") {
const li = document.createElement("li");
const a = document.createElement("a");
a.href = `https://${username}.github.io/${repo}/${item.path}/index.html`;
a.target = '_blank';
a.textContent = item.name;
li.appendChild(a);
ul.appendChild(li);
}
});
fileList.appendChild(ul);
})
.catch(error => {
console.error(error);
});