-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contributors functionality done using github API
- Loading branch information
1 parent
4c237cf
commit 88146e4
Showing
2 changed files
with
28 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
let table = document.getElementById("counthere"); | ||
|
||
function renderContributorsTable(contributors) { | ||
let i = 1; | ||
contributors.forEach(({ login, html_url, contributions }) => { | ||
let row = table.insertRow(i); | ||
let slNoCell = row.insertCell(0); | ||
let userNameCell = row.insertCell(1); | ||
let urlUser = row.insertCell(2); | ||
let noOfContributions = row.insertCell(3); | ||
slNoCell.innerText = i; | ||
userNameCell.innerText = login; | ||
urlUser.innerHTML = `<a href="${html_url}">${html_url}</a>`; | ||
noOfContributions.innerText = contributions; | ||
i++; | ||
}); | ||
document.getElementById("ct").innerHTML = i - 1 + " Contributors"; | ||
} | ||
|
||
fetch("https://api.github.com/repos/yelynn1/tictactoe/contributors") | ||
.then((response) => response.json()) | ||
.then((contributors) => renderContributorsTable(contributors)) | ||
.catch((err) => console.log("Request Failed", err)); |