Last active
January 9, 2024 17:07
-
-
Save DuvanVilladiego/16ec87c5c3fb8363e84afe78fb3cae8a to your computer and use it in GitHub Desktop.
Github graphql Api pinned repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get data from the Github GraphQl api | |
async function get_repo() { | |
try { | |
fetch('https://api.github.com/graphql', { | |
method: 'post', | |
headers: { | |
Authorization: `key, | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
query: `{ | |
user(login: "UserNameHere") { | |
pinnedItems(first: 6, types: REPOSITORY) { | |
nodes { | |
... on Repository { | |
name | |
description | |
url | |
createdAt | |
updatedAt | |
} | |
} | |
} | |
} | |
}` | |
}) | |
}) | |
.then((response) => response.json()).then(x => {repo_data(x.data.user.pinnedItems.nodes)}) | |
}catch(err) { | |
console.log("it was not possible to get the pinned repositories from github" , err); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The name, description, URL, etc are under RepositoryInfo not Repository
Check this Gist