Skip to content

Instantly share code, notes, and snippets.

@TangoPJ
Created August 18, 2022 13:48
Show Gist options
  • Save TangoPJ/ce4f847b6a4850eeb7528ade2e5d5dca to your computer and use it in GitHub Desktop.
Save TangoPJ/ce4f847b6a4850eeb7528ade2e5d5dca to your computer and use it in GitHub Desktop.
import axios from "axios";
const getInfoFromGit = async (urls) => {
const response = [];
for (const url of urls) {
try {
const {
data: { stargazers_count, forks, name, html_url },
} = await axios.get(`https://api.github.com/repos/${url}`);
response.push({
stars: stargazers_count,
forks: forks,
name,
url: html_url,
});
} catch (error) {
console.log(error);
throw new Error(error);
}
}
return response;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment