Skip to content

Instantly share code, notes, and snippets.

@kvn219
Created April 12, 2018 20:21
Show Gist options
  • Save kvn219/a56e7d5b9360bf3a40d8f59aee1dc52a to your computer and use it in GitHub Desktop.
Save kvn219/a56e7d5b9360bf3a40d8f59aee1dc52a to your computer and use it in GitHub Desktop.
Fetch data from the github api.
var axios = require('axios');
handleSubmit: function(){
var username = this.usernameRef.value;
this.usernameRef.value = ‘’;
this.history.pushState(null, “//profile/” + username)
}
function getRepos(username){
return axios.get('https://api.github.com/users/' + username + '/repos');
}
function getUserInfo(username){
return axios.get('https://api.github.com/users/' + username);
}
function addFile(username, password, data){
var url = 'https://api.github.com/repos/'
var userName = 'YOUR_USERNAME'
var repoName = 'REPO_NAME'
var fileName = 'FILE_NAME'
axios.put(urls + userName + repoName + '/contents' + fileName )
}
function
var helpers = {
getGithubInfo: function(username){
return axios.all([getRepos(username), getUserInfo(username)])
.then(function(arr){
return {
repos: arr[0].data,
bio: arr[1].data
}
})
}
}
module.exports = helpers;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment