Skip to content

Instantly share code, notes, and snippets.

@DuvanVilladiego
Last active January 9, 2024 17:07
Show Gist options
  • Save DuvanVilladiego/16ec87c5c3fb8363e84afe78fb3cae8a to your computer and use it in GitHub Desktop.
Save DuvanVilladiego/16ec87c5c3fb8363e84afe78fb3cae8a 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 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);
}
}
@debasishbsws
Copy link

The name, description, URL, etc are under RepositoryInfo not Repository
Check this Gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment