Skip to content

Commit a725166

Browse files
committed
adding latest version to github
1 parent fab162c commit a725166

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

code/script.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const projects = document.getElementById('projects')
55
const API_URL = `https://api.github.com/users/${username}/repos`
66

77

8+
89
/*
910
const options = {
1011
method: 'GET',
@@ -27,6 +28,8 @@ const getRepos = () => {
2728
console.log(forkedRepos)
2829

2930
getPullRequests(forkedRepos)
31+
32+
3033
// injects profile img and user data to the HTML.
3134
imgWrapper.innerHTML =
3235
` <div>
@@ -45,11 +48,11 @@ const getRepos = () => {
4548
<h3>${data.name}</h3></a>
4649
<p>Branch: ${data.default_branch}</p>
4750
<p>Last push: ${new Date(data.pushed_at).toDateString()}</p>
48-
<p ="commits"> Nr of commits: ${data.length}</p>
51+
<p id="repoName" > Nr of commits: </p>
4952
</div>`
5053
})
51-
52-
drawChart(forkedRepos.length)
54+
getPullRequests(forkedRepos)
55+
drawChart(forkedRepos.length)
5356
})
5457
}
5558

@@ -60,23 +63,28 @@ const getPullRequests = (forkedRepos) => {
6063
.then(res => res.json())
6164
.then(data => {
6265
console.log(data)
63-
64-
const myPullRequests = data.find((pull) => pull.user.login === repo.owner.login)
66+
67+
const myPullRequests = data.find((pull) => pull.user.login === repo.owner.login)
6568
console.log(myPullRequests)
66-
const myCommitsURL = myPullRequests.commits_url
67-
console.log(myCommitsURL)
68-
69+
70+
const repoName = repo.name
71+
const myCommitsURL = myPullRequests.commits_url
72+
console.log(myCommitsURL)
73+
console.log(repoName)
74+
75+
getCommits(myCommitsURL, repoName);
76+
})
6977
})
78+
}
79+
80+
const getCommits = (myCommitsURL, repoName) => {
81+
fetch (myCommitsURL)
82+
.then((res) => res.json())
83+
.then(data => {
84+
document.getElementById(repoName).innerHTML = `number of commits ${data.length}`
7085
})
7186
}
7287

73-
const getCommits = (myCommitsURL) => {
74-
fetch (myCommitsURL)
75-
.then((res) => res.json())
76-
.then(data => {
77-
document.getElementById('commits ${repo.name}').innerHTML += data[data.length]
78-
})
79-
}
8088

8189

8290
getRepos()

0 commit comments

Comments
 (0)