Files
hoppscotch/packages/hoppscotch-common/src/helpers/gist.ts
2023-12-06 21:24:29 +05:30

30 lines
581 B
TypeScript

import axios from "axios"
import * as TE from "fp-ts/TaskEither"
export const createGist = (
content: string,
filename: string,
accessToken: string
) => {
return TE.tryCatch(
async () =>
axios.post(
"https://api.github.com/gists",
{
files: {
[filename]: {
content: content,
},
},
},
{
headers: {
Authorization: `token ${accessToken}`,
Accept: "application/vnd.github.v3+json",
},
}
),
(reason) => reason
)
}