Created
December 23, 2013 01:44
-
-
Save h13i32maru/8090689 to your computer and use it in GitHub Desktop.
GitHub APIをJSから実行するスニペット
This file contains 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
var xhr = new XMLHttpRequest() | |
xhr.open('GET', 'https://api.github.com/search/repositories?q=tetris+language:assembly&sort=stars&order=desc', true); | |
xhr.onload = function() { | |
var data = JSON.parse(xhr.responseText); | |
console.log(data); | |
}; | |
// Basic認証 | |
//xhr.setRequestHeader('Authorization', "Basic " + btoa("USERNAME:PASSWORD")); | |
// Personal Access Token. アカウントセッティングから発行可能 | |
xhr.setRequestHeader('Authorization', "token PERSONAL_ACCESS_TOKEN"); | |
xhr.send(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment