Skip to content

Instantly share code, notes, and snippets.

@knowankit
Created September 26, 2021 08:22
Show Gist options
  • Save knowankit/e1ea029718142b4205b5d00a1d99c443 to your computer and use it in GitHub Desktop.
Save knowankit/e1ea029718142b4205b5d00a1d99c443 to your computer and use it in GitHub Desktop.
Get all the stargazers from your git hub
const getAllGithubStars = async () => {
const your_username = 'knowankit'
const URL = `https://api.github.com/users/${your_username}/repos`;
const response = await fetch(URL);
const data = await response.json();
let stars = 0;
for (let i = 0; i < data.length; i++) {
stars += data[i]['stargazers_count'];
}
return stars;
};
export default getAllGithubStars;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment