/loadGist.ts Secret
Created
February 27, 2022 12:34
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