@@ -28,8 +28,10 @@ <h1 class="text-3xl font-bold mb-6 text-center">Contributors</h1>
28
28
29
29
async function fetchContributors ( ) {
30
30
const response = await fetch ( '/api/v2/contributors' ) ;
31
- const contributors = await response . json ( ) ;
32
- return contributors ;
31
+ if ( ! response . ok ) {
32
+ throw new Error ( 'Failed to fetch contributors' ) ;
33
+ }
34
+ return response . json ( ) ;
33
35
}
34
36
35
37
// Function to render issues into the table
@@ -41,9 +43,10 @@ <h1 class="text-3xl font-bold mb-6 text-center">Contributors</h1>
41
43
const listItem = document . createElement ( 'li' ) ;
42
44
listItem . classList . add ( 'flex' , 'justify-center' ) ;
43
45
listItem . innerHTML = `<a target="_blank" href="https://github.com/${ contributor . userName } ">
44
- <div class="flex flex-col justify-center">
46
+ <div class="flex flex-col justify-center items-center ">
45
47
<img class="rounded-full h-32 w-32 bg-slate-600 p-0.5 grow" src="${ contributor . avatarUrl } " alt="Avatar of ${ contributor . userName } ">
46
- <span class="text-center">${ contributor . userName } </span>
48
+ <span class="text-center mt-2 font-medium">${ contributor . userName } </span>
49
+ <span class="text-center text-sm text-gray-500">${ contributor . contributions } Contributions</span>
47
50
</div>
48
51
</a>
49
52
` ;
@@ -55,14 +58,14 @@ <h1 class="text-3xl font-bold mb-6 text-center">Contributors</h1>
55
58
document . addEventListener ( 'DOMContentLoaded' , async ( ) => {
56
59
const loadingElement = document . getElementById ( 'loading' ) ;
57
60
const listElement = document . getElementById ( 'contributors-list' ) ;
58
- let contributors = [ ] ;
59
61
try {
60
- contributors = await fetchContributors ( ) ;
62
+ const contributors = await fetchContributors ( ) ;
61
63
renderContributors ( contributors ) ;
62
64
loadingElement . classList . add ( 'hidden' ) ;
63
65
listElement . classList . remove ( 'hidden' ) ;
64
66
} catch ( error ) {
65
67
loadingElement . textContent = 'Failed to load data. Please try again later.' ;
68
+ console . error ( error ) ;
66
69
}
67
70
} ) ;
68
71
</ script >
0 commit comments