Skip to content

Instantly share code, notes, and snippets.

@h13i32maru
Created December 23, 2013 01:44
Show Gist options
  • Save h13i32maru/8090689 to your computer and use it in GitHub Desktop.
Save h13i32maru/8090689 to your computer and use it in GitHub Desktop.
GitHub APIをJSから実行するスニペット
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