UNPKG

githubinator

Version:

Fetching Data from https://github.com

23 lines (15 loc) 520 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}`).then(res => res.json()); if (res.message) { throw new Error('Invalid Username or Repo ' + res.message); } return res; }; module.exports = getUserRepos;