Get all GitHub Gists of a user
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
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