1- // const userData = document.getElementsById('userData')
1+ // DOM selectors
2+ const projectsContainer = document . getElementById ( 'projects' )
3+
24const username = 'CamillaHallberg'
35let reponame = ''
46
7+ // Authentication
58const API_TOKEN = TOKEN || process . env . API_KEY ;
6-
7- // API's
8- const API_USER = `https://api.github.com/users/${ username } `
9- const API_URL_REPO = `https://api.github.com/users/${ username } /repos`
10-
11- const projectsContainer = document . getElementById ( 'projects' )
12-
139const options = {
1410 method : 'GET' ,
1511 headers : {
1612 Authorization : `${ API_TOKEN } `
1713 }
1814}
15+ // API's
16+ const API_USER = `https://api.github.com/users/${ username } `
17+ const API_URL_REPO = `https://api.github.com/users/${ username } /repos`
1918
19+ // Function to fetch my user data
2020const getUser = ( ) => {
21- fetch ( API_USER , options )
22- . then ( res => res . json ( ) )
23- . then ( user => {
24- console . log ( user , 'my user' ) ;
21+ fetch ( API_USER , options )
22+ . then ( res => res . json ( ) )
23+ . then ( user => {
2524 userData . innerHTML = `
2625 <div class="avatar">
27- <img class="img" src="${ user . avatar_url } " alt="user image">
26+ <img class="img" src="${ user . avatar_url } " alt="user image">
2827 </div>
2928 <div class="info">
30- <h3>${ user . login } </h3>
31- <h4>${ user . bio } </h4>
32- <h4>Location: ${ user . location } </h4>
29+ <h3>${ user . login } </h3>
30+ <h4>${ user . bio } </h4>
31+ <h4>Location: ${ user . location } </h4>
3332 </div>`
3433 } )
3534}
3635getUser ( )
3736
37+ // Function to fetch my repositories
3838const getRepos = ( ) => {
3939 fetch ( API_URL_REPO , options )
4040 . then ( res => res . json ( ) )
4141 . then ( data => {
42- console . log ( data , 'my repos' )
43-
44- // Filtering to get only my forked repos from Technigo
42+ // Filter to get only my forked repos from Technigo
4543 const forkedRepos = data . filter ( ( repo ) => repo . fork && repo . name . startsWith ( 'project-' ) )
46- console . log ( forkedRepos , 'forked repos' )
47-
44+
4845 forkedRepos . forEach ( ( repo ) => {
4946 // Creating unique ID for each forked repo
5047 let projectID = repo . id
51- console . log ( repo )
48+
5249 projectsContainer . innerHTML += `
5350 <div class="projects-card" id="${ projectID } ">
5451 <h3><a href="${ repo . html_url } ">${ repo . name } </a></h3>
5552 <p class="default-branch">Branch: ${ repo . default_branch } </p>
5653 <p>Latest push: ${ new Date ( repo . pushed_at ) . toDateString ( ) } </p>
57- </div>
58- `
54+ </div>`
55+
56+ // Invoking function to get the number of commits for the projects
5957 getCommits ( repo , projectID )
6058 } )
6159 getPullRequests ( forkedRepos )
@@ -84,6 +82,4 @@ const getCommits = (projectsContainer, projectID) => {
8482 } )
8583}
8684
87- getRepos ( )
88-
89- // Kom ihåg att städa i koden + ta bort alla loggar
85+ getRepos ( )
0 commit comments