Created
March 5, 2017 18:11
-
-
Save lonekorean/a49971434a87d56ad760ca1847316b4f to your computer and use it in GitHub Desktop.
Loading a single Gist via the API
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
const url = 'https://api.github.com/gists/8a6a3c508b7c71deb4070d3314900b1f'; | |
function handleDone(data) { | |
// this assumes the gist has a single file | |
let filename = Object.keys(data.files)[0]; | |
let code = data.files[filename].content; | |
$('pre').text(code); | |
$('h1').text(data.description); | |
} | |
function handleFail() { | |
console.log('Something went wrong. :('); | |
} | |
$.get(url).done(handleDone).fail(handleFail); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment