Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orsifrancesco/getgithub
Just a snippet of code to get Github data by user, repo and parameters
https://github.com/orsifrancesco/getgithub
api github github-api html javascript js snippet
Last synced: 25 days ago
JSON representation
Just a snippet of code to get Github data by user, repo and parameters
- Host: GitHub
- URL: https://github.com/orsifrancesco/getgithub
- Owner: orsifrancesco
- License: mit
- Created: 2022-08-07T21:46:29.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-08-07T21:47:07.000Z (over 2 years ago)
- Last Synced: 2024-11-16T20:27:37.892Z (3 months ago)
- Topics: api, github, github-api, html, javascript, js, snippet
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
getGithub
Just a snippet of code to get Github data by user, repo and parameters
### [đŽ Demo on console.log()](https://orsifrancesco.github.io/getGithub)
### âī¸ Licensed under MIT
### đ¤ Author [@orsifrancesco](https://twitter.com/orsifrancesco)
### â [Offer me a coffee](https://www.paypal.com/donate/?business=5EL4L2LDYVH96)
## đĻ Just a snippet of code
```js
function getGithub({ user, id, parameter }) {
return new Promise((resolve, reject) => {if (!user) resolve(false);
const url = `https://api.github.com/search/repositories?q=user:${user}`;
fetch(url)
.then(x => x?.json())
.then(y => {
if (!id) resolve(y?.items);
if (!parameter) resolve(y?.items?.find(el => el.id === id));
resolve(y?.items?.find(el => el.id === id)?.[parameter]);
});
});}
async function fetchData() {
const getUserData = await getGithub({ user: 'orsifrancesco' });
const getRepoData = await getGithub({ user: 'orsifrancesco', id: 265545485 });
const getRepoParameter = await getGithub({ user: 'orsifrancesco', id: 265545485, parameter: 'watchers' });console.log({
getUserData,
getRepoData,
getRepoParameter
});}
fetchData();
```## đšī¸ JSON output
```json
{
"getUserData": [
{
"id": 265545485,
"node_id": "MDEwOlJlcG9zaXRvcnkyNjU1NDU0ODU=",
"name": "instagram-without-api",
...
"watchers": 63
},
{
"id": 519609940,
"node_id": "R_kgDOHvieVA",
...
"forks": 12,
"watchers": 53
},
{
"id": 425524054,
"node_id": "R_kgDOGVz7Vg",
...
}
],
"getRepoData": {
"id": 265545485,
"node_id": "MDEwOlJlcG9zaXRvcnkyNjU1NDU0ODU=",
"name": "instagram-without-api",
"full_name": "orsifrancesco/instagram-without-api",
"private": false,
...
"visibility": "public",
"forks": 2,
"open_issues": 0,
"watchers": 63,
"default_branch": "master",
"score": 1
},
"getRepoParameter": 63
}
```## âī¸ License
Licensed under MIT
## â About
Any feedback to [@orsifrancesco](https://twitter.com/orsifrancesco) and/or [coffee](https://www.paypal.com/donate/?business=5EL4L2LDYVH96) is welcome :)