Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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