|
16 | 16 | } |
17 | 17 |
|
18 | 18 | function main() { |
19 | | - fetch('https://api.github.com/orgs/HackYourFuture/repos?per_page=100L', { method: 'GET' }) |
20 | | - .then(response => response.json()) |
21 | | - .then(json => console.log(json)) |
22 | | - .catch(error => console.log('Network request failed')); |
23 | | - |
24 | 19 | const root = document.getElementById('root'); |
25 | 20 | createAndAppend('select', root, { id: 'dropdown-select' }); |
26 | 21 | createAndAppend('div', root, { id: 'details' }); |
27 | 22 | createAndAppend('div', root, { id: 'contributors' }); |
28 | 23 |
|
29 | 24 | fetch(HYF_REPOS_URL) |
30 | 25 | .then(response => response.json()) |
31 | | - .then( |
32 | | - listOfRepos => |
33 | | - listOfRepos.sort(sortByName).forEach(repoDataObj => { |
34 | | - createAndAppend('option', document.getElementById('dropdown-select'), { |
35 | | - text: repoDataObj.name, |
36 | | - }); |
37 | | - }), |
38 | | - listenerSelect(listOfRepos), |
39 | | - ); |
| 26 | + .then(listOfRepos => { |
| 27 | + listOfRepos.sort(sortByName).forEach(repoDataObj => { |
| 28 | + createAndAppend('option', document.getElementById('dropdown-select'), { |
| 29 | + text: repoDataObj.name, |
| 30 | + }); |
| 31 | + }), |
| 32 | + listenerSelect(listOfRepos); |
| 33 | + }); |
40 | 34 | } |
41 | 35 |
|
42 | 36 | // sort repositories |
|
79 | 73 | let contributors = document.getElementById('contributors'); |
80 | 74 | contributors.innerHTML = ''; |
81 | 75 | fetch(data.contributors_url) |
82 | | - .then(json => data.json()) |
| 76 | + .then(data => data.json()) |
83 | 77 | .then(listOfContributors => { |
84 | 78 | for (let contributor of listOfContributors) { |
85 | 79 | createAndAppend('img', contributors, { src: contributor.avatar_url, class: 'contri' }); |
|
0 commit comments