type Github = {
token: string;
};
/**
* Render a Markdown document
*
*/
export async function main(
auth: Github,
body: {
context?: string;
mode?: "markdown" | "gfm";
text: string;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.github.com/markdown`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 448 days ago