githubHelpers.js 659 B

1234567891011121314151617181920212223242526
  1. import axios from "axios";
  2. const id = "b2226ece2b6fce3bb116";
  3. const sec = "be0525b65ff757d7e70e19589655fe5a41d4e2aa";
  4. const param = `?client_id=${id}&client_secret=${sec}`;
  5. function getUserInfo(username) {
  6. return axios.get(`https://api.github.com/users/${username}${param}`);
  7. }
  8. const helpers = {
  9. getPlayersInfo(players) {
  10. // fetch some data from Github
  11. return axios.all(players.map((username) => {
  12. return getUserInfo(username);
  13. })).then((info) => {
  14. return info.map((item) => {
  15. return item.data;
  16. });
  17. }).catch((err) => {
  18. console.warn("Error in getPlayerInfo", err);
  19. });
  20. }
  21. };
  22. export default helpers;