Skip to content

Commit

Permalink
Making it easy to swap out API for something else
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabriskie committed Aug 12, 2016
1 parent dbfc032 commit 3a4c20e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/utils/github-api.js
@@ -1,16 +1,18 @@
import axios from 'axios';

const BASE_URL = 'https://api.github.com';

export {getRepos, getUserData};

function getRepos(username) {
const url = `https://api.github.com/users/${username}/repos?per_page=250`;
const url = `${BASE_URL}/users/${username}/repos?per_page=250`;
return axios.get(url).then(response => response.data);
}

function getUserData(username) {
return axios.all([
axios.get(`https://api.github.com/users/${username}`),
axios.get(`https://api.github.com/users/${username}/orgs`),
axios.get(`${BASE_URL}/users/${username}`),
axios.get(`${BASE_URL}/users/${username}/orgs`),
])
.then(([user, orgs]) => ({
user: user.data,
Expand Down

0 comments on commit 3a4c20e

Please sign in to comment.