UNPKG

githubinator

Version:

Fetching Data from https://github.com

27 lines (18 loc) 608 B
const fetch = require("node-fetch"); async function getUserRepos(username, repo) { if (!username) { throw new Error('Please, give Github Username'); } if (!repo) { throw new Error('Please, give Repo Name'); } let res = await fetch(`https://api.github.com/repos/${username}/${repo}/forks`).then(res => res.json()); if (res.message) { throw new Error('Invalid Username or Repo ' + res.message); } if (res.length === 0) { throw new Error('No Repos Found'); } return res; }; module.exports = getUserRepos;