From 86a8332400ed0fecf3ff69754971abebd48d25e3 Mon Sep 17 00:00:00 2001 From: Idautterstrom Date: Wed, 29 Sep 2021 19:14:37 +0200 Subject: [PATCH 01/11] APIs added --- code/index.html | 24 +++++++++++++++++++++--- code/script.js | 33 +++++++++++++++++++++++++++++++++ code/style.css | 38 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 90 insertions(+), 5 deletions(-) diff --git a/code/index.html b/code/index.html index 2fb5e0ae..ed0edc9d 100644 --- a/code/index.html +++ b/code/index.html @@ -1,20 +1,38 @@ + Project GitHub Tracker + + + + + + + -

GitHub Tracker

-

Projects:

-
+
+

GitHub Tracker

+

user

+
+ +
+

Projects:

+
+
+ + diff --git a/code/script.js b/code/script.js index e69de29b..b12fa5a2 100644 --- a/code/script.js +++ b/code/script.js @@ -0,0 +1,33 @@ +const API_KEY = "https://api.github.com/users/idautterstrom/repos"; //Endpoint to get all my repos +const API_USER = "https://api.github.com/users/idautterstrom"; //Endpoint to my username and profile picture + +const projects = document.getElementById("projects"); +const user = document.getElementById("user") + +//To get the commits from a PR, you need to get the URL from the commits_url property in the PR json object. +//It might look something like this: +//https://api.github.com/repos/Technigo/project-news-site/pulls/227/commits +//and then do a fetch with that url. + + +fetch(API_USER) +.then((res) => res.json()) +.then((git_user) => { + console.log(git_user) //Mitt repo + user.innerHTML = `username: ${git_user.login}
profilepicture` +}) //kolla när hämtning + +fetch(API_KEY) + .then((res) => res.json()) + .then((git_list) => { + console.log(git_list) //Mitt repo + git_list.forEach(repo => { //Börjat loopa igenom arrayen + console.log(repo.fork) + if (repo.fork === true) { //om ett specifikt värde + projects.innerHTML += `Name of repo: ${repo.name}
Last pushed: ${repo.pushed_at}
Branch: ${repo.default_branch}
Git url: ${repo.git_url}
Number of commits: ${repo.commits_url}
` //formatting av $datum + } + }); + }) + + + \ No newline at end of file diff --git a/code/style.css b/code/style.css index 7c8ad447..6339d1bb 100644 --- a/code/style.css +++ b/code/style.css @@ -1,3 +1,37 @@ +/*When you have the data that you need from the API, +it's time to display it in a good way on the page. +Think about how you want your page to look. +Do you want to use an HTML table? +Maybe the repos could be displayed in a grid format, with all the information inside? +Maybe you want to make it look as closely to GitHub as possible? + +- A list of all repos that are forked from Technigo - KLART +- Your username and profile picture - KLART +- Most recent update (push) for each repo - KLART + formatting +- Name of your default branch for each repo - KLART +- URL to the actual GitHub repo - KLART +- Number of commits for each repo - HOW DO I FETCH THIS URL? +- It should be responsive (mobile first) +- A visualisation, for example through a pie chart, +of how many projects you've done so far, +compared to how many you will do (in total it will be 19 weekly projects 🥳) +using [Chart.js](https://www.chartjs.org/).*/ + body { - background: #FFECE9; -} \ No newline at end of file + background: #ffece9; + font-family: 'Montserrat'; + font-weight: regular; +} + +.profile_picture { + height: 100px; +} + +.logo { + height: 150px; +} + +.footer { + margin-top: 30px; + margin-bottom: 0; +} From fa5de4064607dfc4e16d3a2e07c67b81e07680bc Mon Sep 17 00:00:00 2001 From: Idautterstrom Date: Thu, 30 Sep 2021 16:02:56 +0200 Subject: [PATCH 02/11] added styling --- code/chart.js | 1 + code/index.html | 28 ++++++++++----- code/script.js | 7 ++-- code/style.css | 94 ++++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 109 insertions(+), 21 deletions(-) diff --git a/code/chart.js b/code/chart.js index 92e85a30..8c1c87a3 100644 --- a/code/chart.js +++ b/code/chart.js @@ -2,3 +2,4 @@ const ctx = document.getElementById('chart').getContext('2d') //"Draw" the chart here 👇 + diff --git a/code/index.html b/code/index.html index ed0edc9d..6493ba36 100644 --- a/code/index.html +++ b/code/index.html @@ -16,21 +16,31 @@ -
-

GitHub Tracker

-

user

-
- +
-

Projects:

-
+

GitHub tracker

+
+ +
+
+
- - + +
+

here comes a chart

+ +
+
+ +
+

projects

+
+
diff --git a/code/script.js b/code/script.js index b12fa5a2..e8bd37e5 100644 --- a/code/script.js +++ b/code/script.js @@ -14,8 +14,8 @@ fetch(API_USER) .then((res) => res.json()) .then((git_user) => { console.log(git_user) //Mitt repo - user.innerHTML = `username: ${git_user.login}
profilepicture` -}) //kolla när hämtning + user.innerHTML = `
profilepicture` +}) fetch(API_KEY) .then((res) => res.json()) @@ -24,10 +24,11 @@ fetch(API_KEY) git_list.forEach(repo => { //Börjat loopa igenom arrayen console.log(repo.fork) if (repo.fork === true) { //om ett specifikt värde - projects.innerHTML += `Name of repo: ${repo.name}
Last pushed: ${repo.pushed_at}
Branch: ${repo.default_branch}
Git url: ${repo.git_url}
Number of commits: ${repo.commits_url}
` //formatting av $datum + projects.innerHTML += `
Name of repo: ${repo.name}
Git url: ${repo.git_url}
Last pushed: ${repo.pushed_at}
Branch: ${repo.default_branch}
Number of commits: ${repo.commits_url}
` } }); }) + \ No newline at end of file diff --git a/code/style.css b/code/style.css index 6339d1bb..b03846bf 100644 --- a/code/style.css +++ b/code/style.css @@ -3,13 +3,7 @@ it's time to display it in a good way on the page. Think about how you want your page to look. Do you want to use an HTML table? Maybe the repos could be displayed in a grid format, with all the information inside? -Maybe you want to make it look as closely to GitHub as possible? -- A list of all repos that are forked from Technigo - KLART -- Your username and profile picture - KLART -- Most recent update (push) for each repo - KLART + formatting -- Name of your default branch for each repo - KLART -- URL to the actual GitHub repo - KLART - Number of commits for each repo - HOW DO I FETCH THIS URL? - It should be responsive (mobile first) - A visualisation, for example through a pie chart, @@ -19,19 +13,101 @@ using [Chart.js](https://www.chartjs.org/).*/ body { background: #ffece9; - font-family: 'Montserrat'; - font-weight: regular; + font-family: "Montserrat"; + font-weight: regular; + color: whitesmoke; + background-color: black; + text-align: center; + display: grid; + grid-template-columns: 1fr; + margin-left: 100px; + margin-right: 100px; +} + +.header { + margin-top: 30px; + margin: 30px; +} + +.user-id { + justify-content: center; +} + +.user-name { + margin-top: 30px; + margin-bottom: 30px; + font-family: "Montserrat"; + font-size: medium; + color: grey; + background-color: black; } .profile_picture { height: 100px; + border-radius: 1.5cm; +} + +.pie-chart { + margin-top: 30px; +} + +.project-list { + margin-top: 30px; +} + +.project-container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + text-align: left; + color: black; + margin-top: 30px; + font-size: 0.3cm; +} + +.items { + background-color: darkgray; + margin-bottom: 20px; + padding: 25px; } .logo { - height: 150px; + height: 125px; + margin-right: 10px; +} + +.git-logo { + height: 75px; + border-radius: 1cm; + margin-left: 10px; + margin-bottom: 35px; } .footer { margin-top: 30px; margin-bottom: 0; + align-items: flex-end; +} + +/*tablet menu*/ + +@media (min-width: 768px) { + .project-container { + display: grid; + grid-template-columns: 1fr 1fr; + grid-gap: 10px; + } +} + +/*big screen menu*/ + +@media (min-width: 992px) { + .userChart { + display: grid; + grid-template-columns: 1fr 1fr; + } + .project-container { + grid-template-columns: 1fr 1fr 1fr; + } } From d711bc3a2d1ae2cfbf17a78165f6eec836da6e2d Mon Sep 17 00:00:00 2001 From: Idautterstrom Date: Fri, 1 Oct 2021 15:43:04 +0200 Subject: [PATCH 03/11] added chart and styling --- code/chart.js | 27 +++++++++++++++++++++++ code/index.html | 2 +- code/script.js | 27 +++++++++++++++++++---- code/style.css | 57 ++++++++++++++++++++++--------------------------- 4 files changed, 76 insertions(+), 37 deletions(-) diff --git a/code/chart.js b/code/chart.js index 8c1c87a3..ae207d4d 100644 --- a/code/chart.js +++ b/code/chart.js @@ -3,3 +3,30 @@ const ctx = document.getElementById('chart').getContext('2d') //"Draw" the chart here 👇 +console.log('hello chart') + +const config = { + type: 'doughnut', + data: { + labels: [ + 'Finished projects', + 'Projects left' + ], + datasets: [{ + label: 'My First Dataset', + data: [6, 20-6], + backgroundColor: [ + '1a1b1a', + 'black' + ], + borderColor: [ + 'none' + ], + hoverOffset: 4 + }] + }, + }; + +const repoChart = new Chart(ctx, config) + + \ No newline at end of file diff --git a/code/index.html b/code/index.html index 6493ba36..9268a84b 100644 --- a/code/index.html +++ b/code/index.html @@ -13,6 +13,7 @@ + @@ -28,7 +29,6 @@

GitHub tracker

-

here comes a chart

diff --git a/code/script.js b/code/script.js index e8bd37e5..a7e3baee 100644 --- a/code/script.js +++ b/code/script.js @@ -4,7 +4,7 @@ const API_USER = "https://api.github.com/users/idautterstrom"; //Endpoint to my const projects = document.getElementById("projects"); const user = document.getElementById("user") -//To get the commits from a PR, you need to get the URL from the commits_url property in the PR json object. +//To get the commits from a PR, you need to get the URL from the commits_url property in the PR json object. //It might look something like this: //https://api.github.com/repos/Technigo/project-news-site/pulls/227/commits //and then do a fetch with that url. @@ -13,8 +13,10 @@ const user = document.getElementById("user") fetch(API_USER) .then((res) => res.json()) .then((git_user) => { - console.log(git_user) //Mitt repo - user.innerHTML = `
profilepicture` + console.log(git_user) //Min user + user.innerHTML = + `${git_user.login} +
profilepicture` }) fetch(API_KEY) @@ -24,11 +26,28 @@ fetch(API_KEY) git_list.forEach(repo => { //Börjat loopa igenom arrayen console.log(repo.fork) if (repo.fork === true) { //om ett specifikt värde - projects.innerHTML += `
Name of repo: ${repo.name}
Git url: ${repo.git_url}
Last pushed: ${repo.pushed_at}
Branch: ${repo.default_branch}
Number of commits: ${repo.commits_url}
` + projects.innerHTML += + `
+

Name of repo: ${repo.name}

+

Git url: ${repo.git_url}

+

Branch: ${repo.default_branch}

+

Last pushed: ${new Date(repo.pushed_at).toDateString()}

+

Number of commits: ${repo.commits_url}

//how do I fetch the URL from this? +
` } }); }) + const fetchPullRequests = (allRepositories) => { + allRepositories.forEach(repo => { + fetch(repo) + }) + } + + + + + \ No newline at end of file diff --git a/code/style.css b/code/style.css index b03846bf..5bfff359 100644 --- a/code/style.css +++ b/code/style.css @@ -1,20 +1,6 @@ -/*When you have the data that you need from the API, -it's time to display it in a good way on the page. -Think about how you want your page to look. -Do you want to use an HTML table? -Maybe the repos could be displayed in a grid format, with all the information inside? - -- Number of commits for each repo - HOW DO I FETCH THIS URL? -- It should be responsive (mobile first) -- A visualisation, for example through a pie chart, -of how many projects you've done so far, -compared to how many you will do (in total it will be 19 weekly projects 🥳) -using [Chart.js](https://www.chartjs.org/).*/ - body { background: #ffece9; font-family: "Montserrat"; - font-weight: regular; color: whitesmoke; background-color: black; text-align: center; @@ -34,25 +20,24 @@ body { } .user-name { - margin-top: 30px; - margin-bottom: 30px; - font-family: "Montserrat"; - font-size: medium; - color: grey; - background-color: black; + color: rgb(135, 133, 133); + text-decoration: none; } -.profile_picture { - height: 100px; - border-radius: 1.5cm; +.user-name:hover { + color: whitesmoke; } -.pie-chart { - margin-top: 30px; +.profile_picture { + width: 100px; + border-radius: 4cm; + margin-top: 25px; } -.project-list { - margin-top: 30px; +.pie-chart { + width: 50%; + margin-top: 40px; + margin-left: 25%; } .project-container { @@ -61,15 +46,15 @@ body { align-items: center; justify-content: center; text-align: left; - color: black; - margin-top: 30px; + color: whitesmoke; font-size: 0.3cm; } .items { - background-color: darkgray; - margin-bottom: 20px; + background-color: #1a1b1a; + margin-bottom: 15px; padding: 25px; + border-radius: 0.3cm; } .logo { @@ -96,13 +81,21 @@ body { .project-container { display: grid; grid-template-columns: 1fr 1fr; - grid-gap: 10px; + grid-gap: 20px; } } /*big screen menu*/ @media (min-width: 992px) { + .profile_picture { + width: 250px; + } + + .pie-chart { + margin-top: 0; + } + .userChart { display: grid; grid-template-columns: 1fr 1fr; From 5d714cb560c54e834c419ffec279f9001d3980b5 Mon Sep 17 00:00:00 2001 From: Idautterstrom Date: Fri, 1 Oct 2021 15:54:13 +0200 Subject: [PATCH 04/11] justified content for mobile --- code/script.js | 6 ------ code/style.css | 8 +++----- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/code/script.js b/code/script.js index a7e3baee..462a6b16 100644 --- a/code/script.js +++ b/code/script.js @@ -38,12 +38,6 @@ fetch(API_KEY) }); }) - const fetchPullRequests = (allRepositories) => { - allRepositories.forEach(repo => { - fetch(repo) - }) - } - diff --git a/code/style.css b/code/style.css index 5bfff359..bb682501 100644 --- a/code/style.css +++ b/code/style.css @@ -6,13 +6,11 @@ body { text-align: center; display: grid; grid-template-columns: 1fr; - margin-left: 100px; - margin-right: 100px; } .header { margin-top: 30px; - margin: 30px; + margin-bottom: 40px; } .user-id { @@ -58,12 +56,12 @@ body { } .logo { - height: 125px; + height: 100px; margin-right: 10px; } .git-logo { - height: 75px; + height: 50px; border-radius: 1cm; margin-left: 10px; margin-bottom: 35px; From bb765a299e6b93ca497e3da1949e49a5a7a21c99 Mon Sep 17 00:00:00 2001 From: Idautterstrom Date: Fri, 1 Oct 2021 17:58:31 +0200 Subject: [PATCH 05/11] started with commits fetch --- code/script.js | 32 +++++++++++++++++++++++++------- code/style.css | 5 +++-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/code/script.js b/code/script.js index 462a6b16..9b98dfe2 100644 --- a/code/script.js +++ b/code/script.js @@ -1,6 +1,7 @@ const API_KEY = "https://api.github.com/users/idautterstrom/repos"; //Endpoint to get all my repos const API_USER = "https://api.github.com/users/idautterstrom"; //Endpoint to my username and profile picture + const projects = document.getElementById("projects"); const user = document.getElementById("user") @@ -29,19 +30,36 @@ fetch(API_KEY) projects.innerHTML += `

Name of repo: ${repo.name}

-

Git url: ${repo.git_url}

+

${repo.git_url}

Branch: ${repo.default_branch}

Last pushed: ${new Date(repo.pushed_at).toDateString()}

-

Number of commits: ${repo.commits_url}

//how do I fetch the URL from this? +

Number of commits:

` - } + + getPullRequests(git_list) + } }); }) + //Remember to pass along your filtered repos as an argument when +//you are calling this function +const getPullRequests = (repos) => { + //Get all the PRs for each project. + repos.forEach(repo => { + fetch('https://api.github.com/repos/technigo/${repo.name}/pulls') + .then(res => res.json()) + .then(data => { + const myPullRequests = data.find((pull) => pull.user.login === repo.owner.login) //Find only the PR that you made by comparing pull.user.login with repo.owner.login - - - + if (myPullRequests) { + fetchCommits(myPullRequests.commits_url, repo.name); + } else { + document.getElementById(`commits-${repo.name}`).innerHTML = + `No pull requests made`; + } + }) + }) + } - \ No newline at end of file + \ No newline at end of file diff --git a/code/style.css b/code/style.css index bb682501..3d3d7e8b 100644 --- a/code/style.css +++ b/code/style.css @@ -41,8 +41,8 @@ body { .project-container { display: flex; flex-direction: column; - align-items: center; - justify-content: center; + width: 50%; + margin-left: 25%; text-align: left; color: whitesmoke; font-size: 0.3cm; @@ -98,6 +98,7 @@ body { display: grid; grid-template-columns: 1fr 1fr; } + .project-container { grid-template-columns: 1fr 1fr 1fr; } From a099666d5124353ddd0a7fd98e42c088119d23e3 Mon Sep 17 00:00:00 2001 From: Idautterstrom Date: Mon, 4 Oct 2021 09:37:43 +0200 Subject: [PATCH 06/11] styling --- code/script.js | 34 +++++++++++++++++++++------------- code/style.css | 7 ++----- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/code/script.js b/code/script.js index 9b98dfe2..2e9b14c1 100644 --- a/code/script.js +++ b/code/script.js @@ -5,12 +5,6 @@ const API_USER = "https://api.github.com/users/idautterstrom"; //Endpoint to my const projects = document.getElementById("projects"); const user = document.getElementById("user") -//To get the commits from a PR, you need to get the URL from the commits_url property in the PR json object. -//It might look something like this: -//https://api.github.com/repos/Technigo/project-news-site/pulls/227/commits -//and then do a fetch with that url. - - fetch(API_USER) .then((res) => res.json()) .then((git_user) => { @@ -33,10 +27,10 @@ fetch(API_KEY)

${repo.git_url}

Branch: ${repo.default_branch}

Last pushed: ${new Date(repo.pushed_at).toDateString()}

-

Number of commits:

+

Number of commits:

` - getPullRequests(git_list) + /* getPullRequests(git_list); */ } }); }) @@ -44,9 +38,23 @@ fetch(API_KEY) //Remember to pass along your filtered repos as an argument when //you are calling this function -const getPullRequests = (repos) => { - //Get all the PRs for each project. - repos.forEach(repo => { +/* const numberOfCommits = (repos) => { */ + /* //Get all the PRs for each project. + const base_url = "http://api.github.com"; + const owner = "idautterstrom"; + const sha = "master"; + let compare_url = + base_url + "/repos/" + owner + "/" + repo.name + "/commits" + sha; + fetch(compare_url) + .then((res) => res.json()) + .then((data) =>{ + console.log(data); + return data.stats.total; + } +)} */ + + +/* repos.forEach(repo => { fetch('https://api.github.com/repos/technigo/${repo.name}/pulls') .then(res => res.json()) .then(data => { @@ -59,7 +67,7 @@ const getPullRequests = (repos) => { `No pull requests made`; } }) - }) - } + }) */ +/* )} */ \ No newline at end of file diff --git a/code/style.css b/code/style.css index 3d3d7e8b..8177fd48 100644 --- a/code/style.css +++ b/code/style.css @@ -13,10 +13,6 @@ body { margin-bottom: 40px; } -.user-id { - justify-content: center; -} - .user-name { color: rgb(135, 133, 133); text-decoration: none; @@ -80,6 +76,7 @@ body { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 20px; + justify-content: center; } } @@ -98,7 +95,7 @@ body { display: grid; grid-template-columns: 1fr 1fr; } - + .project-container { grid-template-columns: 1fr 1fr 1fr; } From 6e8be1e27b5ca3e819067aac196f5a4a5e04b31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ida=20Utterstr=C3=B6m?= <80784577+Idautterstrom@users.noreply.github.com> Date: Tue, 5 Oct 2021 13:06:45 +0200 Subject: [PATCH 07/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1613a3b0..a722daca 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,4 @@ Describe how you approached to problem, and what tools and techniques you used t ## View it live -Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. +https://project-github-tracker-idautterstrom.netlify.app From dd7f9bb45581dd00b217d3a614d437f2e11d9988 Mon Sep 17 00:00:00 2001 From: Idautterstrom Date: Tue, 5 Oct 2021 17:23:58 +0200 Subject: [PATCH 08/11] started method for commits --- .DS_Store | Bin 0 -> 6148 bytes code/script.js | 44 +++++++++++++------------------------------- 2 files changed, 13 insertions(+), 31 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..01625912d654f181b4393c80d202bb2d9e546436 GIT binary patch literal 6148 zcmeH~F^LWILo3EBZM)-ySy`wq8Z(Te9ES6D!Ft zGBE%h|QedILw&$at|7ZGN^Z%knsT7a` zZ>E3^r?1nIFO_HO%j)FR3$i9#Co44l2!sp@Qs7?| Fcmh=m5}*J8 literal 0 HcmV?d00001 diff --git a/code/script.js b/code/script.js index 2e9b14c1..8a77fba3 100644 --- a/code/script.js +++ b/code/script.js @@ -21,53 +21,35 @@ fetch(API_KEY) git_list.forEach(repo => { //Börjat loopa igenom arrayen console.log(repo.fork) if (repo.fork === true) { //om ett specifikt värde - projects.innerHTML += + let commits = numberOfCommits(repo) //När vi anropar, Skickar med objektet till metoden + projects.innerHTML += `

Name of repo: ${repo.name}

${repo.git_url}

Branch: ${repo.default_branch}

Last pushed: ${new Date(repo.pushed_at).toDateString()}

-

Number of commits:

+

Number of commits: ${commits}

` - - /* getPullRequests(git_list); */ } }); }) //Remember to pass along your filtered repos as an argument when -//you are calling this function + //you are calling this function -/* const numberOfCommits = (repos) => { */ - /* //Get all the PRs for each project. - const base_url = "http://api.github.com"; +const numberOfCommits = (repo) => { + const base_url = "https://api.github.com/"; const owner = "idautterstrom"; const sha = "master"; - let compare_url = - base_url + "/repos/" + owner + "/" + repo.name + "/commits" + sha; + console.log(repo.name); + let compare_url = base_url + "/repos/" + owner + "/" + repo.name + "/commits"; fetch(compare_url) .then((res) => res.json()) - .then((data) =>{ - console.log(data); - return data.stats.total; - } -)} */ - - -/* repos.forEach(repo => { - fetch('https://api.github.com/repos/technigo/${repo.name}/pulls') - .then(res => res.json()) - .then(data => { - const myPullRequests = data.find((pull) => pull.user.login === repo.owner.login) //Find only the PR that you made by comparing pull.user.login with repo.owner.login + .then((data) => { + console.log(data.length); + return data.length; + }); + }; - if (myPullRequests) { - fetchCommits(myPullRequests.commits_url, repo.name); - } else { - document.getElementById(`commits-${repo.name}`).innerHTML = - `No pull requests made`; - } - }) - }) */ -/* )} */ \ No newline at end of file From f0d343db96fc84897315d36b9aedadf35070df06 Mon Sep 17 00:00:00 2001 From: Idautterstrom Date: Thu, 7 Oct 2021 08:13:16 +0200 Subject: [PATCH 09/11] commits function --- code/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/script.js b/code/script.js index 8a77fba3..aace8c8e 100644 --- a/code/script.js +++ b/code/script.js @@ -40,7 +40,7 @@ fetch(API_KEY) const numberOfCommits = (repo) => { const base_url = "https://api.github.com/"; const owner = "idautterstrom"; - const sha = "master"; +/* const sha = "master"; */ console.log(repo.name); let compare_url = base_url + "/repos/" + owner + "/" + repo.name + "/commits"; fetch(compare_url) From 6b45e9a7ef85498dd015ae181b29c347e69fa1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ida=20Utterstr=C3=B6m?= <80784577+Idautterstrom@users.noreply.github.com> Date: Wed, 13 Oct 2021 16:02:37 +0200 Subject: [PATCH 10/11] Update script.js --- code/script.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/code/script.js b/code/script.js index aace8c8e..22312150 100644 --- a/code/script.js +++ b/code/script.js @@ -17,11 +17,11 @@ fetch(API_USER) fetch(API_KEY) .then((res) => res.json()) .then((git_list) => { - console.log(git_list) //Mitt repo - git_list.forEach(repo => { //Börjat loopa igenom arrayen + console.log(git_list) + git_list.forEach(repo => { console.log(repo.fork) - if (repo.fork === true) { //om ett specifikt värde - let commits = numberOfCommits(repo) //När vi anropar, Skickar med objektet till metoden + if (repo.fork) { + let commits = numberOfCommits(repo) projects.innerHTML += `

Name of repo: ${repo.name}

@@ -34,15 +34,11 @@ fetch(API_KEY) }); }) - //Remember to pass along your filtered repos as an argument when - //you are calling this function - const numberOfCommits = (repo) => { const base_url = "https://api.github.com/"; const owner = "idautterstrom"; -/* const sha = "master"; */ console.log(repo.name); - let compare_url = base_url + "/repos/" + owner + "/" + repo.name + "/commits"; + let compare_url = base_url + "repos/" + owner + "/" + repo.name + "/commits"; fetch(compare_url) .then((res) => res.json()) .then((data) => { @@ -52,4 +48,4 @@ const numberOfCommits = (repo) => { }; - \ No newline at end of file + From d9365d5a31826b03861c3fb463d38a8153e109f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ida=20Utterstr=C3=B6m?= <80784577+Idautterstrom@users.noreply.github.com> Date: Wed, 13 Oct 2021 16:04:21 +0200 Subject: [PATCH 11/11] Update script.js --- code/script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/code/script.js b/code/script.js index 22312150..58c89cb0 100644 --- a/code/script.js +++ b/code/script.js @@ -37,6 +37,7 @@ fetch(API_KEY) const numberOfCommits = (repo) => { const base_url = "https://api.github.com/"; const owner = "idautterstrom"; + const sha = "master"; console.log(repo.name); let compare_url = base_url + "repos/" + owner + "/" + repo.name + "/commits"; fetch(compare_url)