repo-finder
v1.1.1
Published
Gets repository list from a specified GitHub user, using the GitHub API
Downloads
14
Readme
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-finder
Using yarn
$ yarn add repo-finder
Using pnpm
$ pnpm add repo-finder
Using bun
$ bun i repo-finder
Usage
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:
getUserRepos
andgetUserData
implementasync/await
which is part of ES2017 and is not supported by some older browsers.