1.1.1 • Published 2 years ago
repo-finder v1.1.1
repo-finder
Gets user and repo info for a specified GitHub user, using the GitHub API.
- User info is gotten from
https://api.github.com/users/USERNAME - User repos are gotten from
https://api.github.com/users/USERNAME/repos
Installation
Using npm
$ npm install repo-finderUsing yarn
$ yarn add repo-finderUsing pnpm
$ pnpm add repo-finderUsing bun
$ bun i repo-finderUsage
Once the package is installed, you can import it in your code using both require or import depending on whether you use CommonJS or ESModules.
import { getUserData, getUserRepos } from "repo-finder";
const { getUserData, getUserRepos } = require("repo-finder");Both functions return a promise containing the raw JSON data from the GitHub API. You can then format that data however you like.
Example
const { getUserRepos } = require("repo-finder");
const data = getUserRepos(username);
data.then((repos) => {
console.log("Total repos: " + repos.length);
repos.forEach((repo) => {
console.log(repo.name);
});
});Note:
getUserReposandgetUserDataimplementasync/awaitwhich is part of ES2017 and is not supported by some older browsers.