Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomparte authored Apr 1, 2024
1 parent a6baa86 commit b19bef8
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
document.addEventListener('DOMContentLoaded', function () {
fetch('https://api.github.com/users/tomparte/repos')
.then(response => response.json())
.then(data => {
const container = document.getElementById('repo-container');
data.forEach(repo => {
const div = document.createElement('div');
div.className = 'repo';
div.innerHTML = `<h2>${repo.name}</h2><p>${repo.description || ''}</p><a href="${repo.html_url}" target="_blank">View Repo</a>`;
container.appendChild(div);
});
})
.catch(error => console.log('Error:', error));
});
// Récupérer les dépôts publics de l'utilisateur
fetch('https://api.github.com/users/tomparte/repos')
.then(response => response.json())
.then(repos => {
const repoContainer = document.querySelector('.repo-container');

repos.forEach(repo => {
const repoCard = document.createElement('div');
repoCard.classList.add('repo-card');

const repoName = document.createElement('h2');
repoName.textContent = repo.name;

const repoDescription = document.createElement('p');
repoDescription.textContent = repo.description || 'Pas de description disponible.';

const repoLink = document.createElement('a');
repoLink.href = repo.html_url;
repoLink.textContent = 'Voir le dépôt';

repoCard.appendChild(repoName);
repoCard.appendChild(repoDescription);
repoCard.appendChild(repoLink);

repoContainer.appendChild(repoCard);
});
})
.catch(error => {
console.error('Erreur lors de la récupération des dépôts :', error);
});

0 comments on commit b19bef8

Please sign in to comment.