content must include description public and files in object
token from setting and developer in github
Last active
November 22, 2024 22:33
-
-
Save Madmals/264d16182361143f118098ea6857d244 to your computer and use it in GitHub Desktop.
FETCH POST METHOD ON GITHUB GIST
This file contains hidden or 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
content = { | |
"description": "TITLE ", | |
"public": false, | |
"files": | |
{ | |
"post1.md": { | |
"content": "THIS IS WHERE CONTENT WILL BE PUT" | |
} | |
} | |
} | |
const token = your access_token' | |
const githubgist = async ()=>{ | |
let res = await fetch('https://api.github.com/gists', | |
{ | |
headers: {'Authorization': `token ${token}`, | |
'Content-type': 'application/json'}, | |
method:'post', | |
body:JSON.stringify(content) | |
}) | |
let data = await (res.json()) | |
console.log(data) | |
} | |
githubgist() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment