Skip to content

Instantly share code, notes, and snippets.

@debasishbsws
Forked from DuvanVilladiego/pinnedRepositories
Last active May 28, 2022 11:05
Show Gist options
  • Save debasishbsws/f7ca11128aa73e1f241be499e706b385 to your computer and use it in GitHub Desktop.
Save debasishbsws/f7ca11128aa73e1f241be499e706b385 to your computer and use it in GitHub Desktop.
Github graphql Api pinned repositories
//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 RepositoryInfo {
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