Advertisement
bai_onzi

fetchGitRepositoryInfo

Sep 7th, 2023
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fetchGitRepositoryInfo = async () => {
  2.     try {
  3.       const [owner, repoName] = gitHubRepoLink.split('/').slice(+2);
  4.       const response = await fetch('https://api.github.com/repos/${owner}/${repoName}');
  5.       if(!response.ok){
  6.         console.error('GitHub API Error', response.statusText);
  7.         return;
  8.       }
  9.  
  10.       const repoInfo = await response.json();
  11.  
  12.       const issuesCount = repoInfo.open_issues_count;
  13.       const totalDownloads = repoInfo.watchers_count;
  14.       const lastUpdate = new Date(repoInfo.updated_at).toLocaleDateString();
  15.     }catch(error){
  16.       console.error('Error fetching GitHub repo info', error)
  17.   }
  18.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement