Skip to content

Commit c14cdb5

Browse files
committed
added dynamic id
1 parent ec75984 commit c14cdb5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

code/script.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ const fetchRepos = () => {
3939
(reposContainer.innerHTML += `
4040
<h3>${repo.name}</h3>
4141
<p><a href="${repo.html_url}" target="blank">${repo.html_url}</a></p>
42-
<p>${repo.default_branch}</p>
43-
<p>${repo.pushed_at.toString().slice(0, 10)}</p>
42+
<p>with default branch ${repo.default_branch}</p>
43+
<p>Recent push: ${new Date(repo.pushed_at).toDateString()}</p>
44+
<p id="commit-${repo.name}">Commits: </p>
4445
`)
4546
);
4647
drawChart(forkedRepos.length);
@@ -67,7 +68,7 @@ const getPullRequests = (repos) => {
6768
(pull) => pull.user.login === repo.owner.login
6869
);
6970

70-
showCommits(filteredPull.commits_url);
71+
showCommits(filteredPull.commits_url, repo.name);
7172

7273
//TODO
7374
//1. Find only the PR that you made by comparing pull.user.login
@@ -81,14 +82,12 @@ const getPullRequests = (repos) => {
8182
});
8283
};
8384

84-
const showCommits = (url) => {
85+
const showCommits = (url, myRepoName) => {
8586
fetch(url)
8687
.then((res) => res.json())
8788
.then((data) => {
8889
console.log(data);
89-
commitsContainer.innerHTML += `
90-
<p>Commit: ${data.length}</p>
91-
`;
90+
document.getElementById(`commit-${myRepoName}`).innerHTML += data.length;
9291
});
9392
};
9493

0 commit comments

Comments
 (0)