Skip to content

Instantly share code, notes, and snippets.

@Uvacoder
Created December 16, 2021 13:13
Show Gist options
  • Save Uvacoder/75e698d3f9c3b8a4a8f6dbb51f18bf6c to your computer and use it in GitHub Desktop.
Save Uvacoder/75e698d3f9c3b8a4a8f6dbb51f18bf6c to your computer and use it in GitHub Desktop.
Get all GitHub Gists of a user
async function getGithubGists() {
const githubUsername = 'octocat'
const gists = await fetch(
`https://api.github.com/users/${githubUsername}/gists`
)
const gistsJson = await gists.json()
const snippets = []
gistsJson.map((gist) => {
snippets.push({
title: gist.files[Object.keys(gist.files)[0]].filename,
description: gist.description,
code: gist.html_url
})
})
return snippets
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment