1- const USER = "mamite100" ;
2- const REPOS_URL = `https://api.github.com/users/${ USER } /repos` ;
3- const projectsContainer = document .
4- getElementById ( "projects" ) ;
1+ /* my user*/
2+ /*can't get my USER*/
3+ const USER = 'mamite100' ;
4+
5+ const REPOS_URL = `https://api.github.com/users/${ USER } /repos` ;
6+
7+ const PROFILE_URL = `https://api.github.com/users/${ USER } `
8+
9+ const profileContainer = document . getElementById ( 'profile-container' )
10+ const projectsContainer = document . getElementById ( 'projects' ) ;
11+
12+ const fetchProfile = ( ) => {
13+ fetch ( PROFILE_URL )
14+ . then ( res => res . json ( ) )
15+ . then ( profileData => {
16+ profileContainer . innerHTML += `
17+ <img src=${ profileData . avatar_url } class='profile-img'>
18+ <h2>${ profileData . name } </h2>
19+ <p>${ profileData . login } </p>`
20+ } ) ;
21+ }
522
623const fetchRepositories = ( ) => {
7- fetch ( REPOS_URL )
8- . then ( ( res ) => res . json ( ) )
9- . then ( ( data ) => {
10- const technigoRepositories = data . filter ( ( repo ) => repo . name . includes ( "project-" ) && repo . fork
11- ) ;
12- technigoRepositories . forEach (
13- ( repo ) => {
14- projectsContainer . innerHTML += `
15- <div>
16- <a href="${ repo . html_url } " > ${ repo . name } with default branch
17- ${ repo . default_branch } </a>
18- <p> Recent push: ${ new Date ( repo . pushed_at ) . toDateString ( ) } </p>
19- <p id="commit-${ repo . name } "> Commits: </p>
20- </div>
24+ fetch ( REPOS_URL )
25+ . then ( ( res ) => res . json ( ) )
26+ . then ( ( data ) => {
27+ const technigoRepositories = data . filter (
28+ ( repo ) => repo . name . includes ( 'project-' ) && repo . fork
29+ ) ;
30+
31+ technigoRepositories . forEach ( ( repo ) => {
32+ projectsContainer . innerHTML += `
33+ <div>
34+ <a href="${ repo . html_url } ">${ repo . name } with default branch ${
35+ repo . default_branch
36+ } </a>
37+ <p>Recent push: ${ new Date ( repo . pushed_at ) . toDateString ( ) } </p>
38+ <p id="commit-${ repo . name } ">Commits amount: </p>
39+ </div>
2140 ` ;
22- } ) ;
23- } ) ;
41+
42+ } ) ;
43+
44+ fetchPullRequestsArray ( technigoRepositories ) ;
45+
46+ //draw chart with technigoRepos data. I can't get the char?
47+ drawBarChart ( technigoRepos . length ) ;
48+ } ) ;
2449} ;
2550
26- const fetchPullRequestsArray = ( allRepositories ) => {
27- allRepositories . forEach ( ( repo ) => {
28- const PULL_URL =
29- `https://api.github.com/repos/Technigo/${ repo . name } /pulls?per_page=100` ;
30- fetch ( PULL_URL )
31- . then ( ( res ) => res . json ( ) )
32- . then ( ( data ) => {
33- const myPullRequest = data . find (
34- ( pull ) => pull . user . login === repo . owner . login
35- ) ;
36- if ( myPullRequest ) {
51+ const fetchPullRequestsArray = ( allRepositories ) => {
52+ allRepositories . forEach ( ( repo ) => {
53+ const PULL_URL = `https://api.github.com/repos/Technigo/${ repo . name } /pulls?per_page=100` ;
54+
55+ fetch ( PULL_URL )
56+ . then ( ( res ) => res . json ( ) )
57+ . then ( ( data ) => {
58+ const myPullRequest = data . find (
59+ ( pull ) => pull . user . login === repo . owner . login
60+ ) ;
61+
62+ if ( myPullRequest ) {
3763 fetchCommits ( myPullRequest . commits_url , repo . name ) ;
3864 } else {
3965 document . getElementById ( `commit-${ repo . name } ` ) . innerHTML =
40- 'No pull request yet done : ( ' ;
66+ 'No pull request yet done :( ' ;
4167 }
4268 } ) ;
4369 } ) ;
@@ -51,4 +77,4 @@ const fetchCommits = (myCommitsUrl, myRepoName) => {
5177 } ) ;
5278} ;
5379
54- fetchRepositories ( ) ;
80+ fetchRepositories ( ) ;
0 commit comments