type Github = {
token: string;
};
/**
* Create a gist
* Allows you to add a new gist with one or more files.
**Note:** Don't name your files "gistfile" with a numerical suffix. This is the format of the automatic naming scheme that Gist uses internally.
*/
export async function main(
auth: Github,
body: {
description?: string;
files: { [k: string]: { content: string; [k: string]: unknown } };
public?: boolean | ("true" | "false");
[k: string]: unknown;
}
) {
const url = new URL(`https://api.github.com/gists`);
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.json();
}
Submitted by hugo697 21 days ago
type Github = {
token: string;
};
/**
* Create a gist
* Allows you to add a new gist with one or more files.
**Note:** Don't name your files "gistfile" with a numerical suffix. This is the format of the automatic naming scheme that Gist uses internally.
*/
export async function main(
auth: Github,
body: {
description?: string;
files: { [k: string]: { content: string; [k: string]: unknown } };
public?: boolean | ("true" | "false");
[k: string]: unknown;
}
) {
const url = new URL(`https://api.github.com/gists`);
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.json();
}
Submitted by hugo697 581 days ago