-
-
Save brunosabot/0452d814c076b772dbb91ada500e999d to your computer and use it in GitHub Desktop.
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
import fetch from "node-fetch"; | |
interface GistJsonResponse { | |
files: string[]; | |
} | |
async function loadGist(id: string) { | |
const url = `https://gist.github.com/${id}`; | |
const jsonResponse = await fetch(`${url}.json`); | |
const jsonData = await (jsonResponse.json() as Promise<GistJsonResponse>); | |
const data = await Promise.all( | |
jsonData.files.map((file) => | |
fetch(`${url}/raw/?file=${file}`).then((r) => r.text()) | |
) | |
); | |
return [data, jsonData]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment