-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.js
More file actions
24 lines (20 loc) · 823 Bytes
/
javascript.js
File metadata and controls
24 lines (20 loc) · 823 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
const btnRepos = document.getElementById("btnRepos")
const divResult = document.getElementById("divResult")
btnRepos.addEventListener("click", getRepos)
async function getRepos() {
clear();
const url = "https://api.github.com/search/repositories?q=stars:0..300000"
const response = await fetch(url)
const result = await response.json()
result.items.forEach(i=>{
const anchor = document.createElement("a")
anchor.href = i.html_url;
anchor.textContent = i.full_name;
divResult.appendChild(anchor)
divResult.appendChild(document.createElement("br"))
})
}
function clear(){
while(divResult.firstChild)
divResult.removeChild(divResult.firstChild)
}