Created
December 16, 2021 13:13
-
-
Save Uvacoder/75e698d3f9c3b8a4a8f6dbb51f18bf6c to your computer and use it in GitHub Desktop.
Get all GitHub Gists of a user
This file contains hidden or 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