Skip to content

Instantly share code, notes, and snippets.

@alundiak
Last active September 23, 2017 20:58
Show Gist options
  • Save alundiak/1e39a01059d61bd33d21c316a2bf4ef9 to your computer and use it in GitHub Desktop.
Save alundiak/1e39a01059d61bd33d21c316a2bf4ef9 to your computer and use it in GitHub Desktop.
const apiUrl = 'https://api.github.com';
export default function getInfo(TOKEN, myArrayOfRepositories) {
myArrayOfRepositories.forEach(function(repository) {
let strUrl = apiUrl + '/repos/' + repository.owner + '/' + repository.name;
let options = {
headers: {
// 'Content-Type': 'application/json', // OPTIONS => GET
// 'Content-Type': 'text/plain', // doesn't matter. Anyway OPTIONS => GET
'Authorization': `token ${TOKEN}`
}
}
fetch(strUrl, options)
.then(response => response.json())
.then(data => console.log(data));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment