Advertisement
Guest User

AlexCode

a guest
Mar 26th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require("axios");
  2.  
  3. function getUser(username) {
  4.     const queryUrl = `https://api.github.com/users/${username}/events/public`;
  5.    
  6.     let pushEvent;
  7.     let pushEventEmail;
  8.     let pushEventAvatar;
  9.     let pushArray;
  10.    
  11.     axios.get(queryUrl).then(function(response) {
  12.       const responseData = response.data;
  13.       // console.log(responseData)
  14.       // loop - pull first one with PushEvent
  15.  
  16.  
  17.       for (entry of responseData) {
  18.         if (entry.type === "PushEvent") {
  19.           pushEvent = entry;
  20.         }
  21.       }
  22.      
  23.       pushEventEmail = pushEvent.payload.commits[0].author.email;
  24.       pushEventAvatar = pushEvent.actor.avatar_url;
  25.      
  26.       pushArray = [pushEventEmail, pushEventAvatar];
  27.       // console.log(pushArray)
  28.      
  29.     }
  30.  
  31.    
  32.   );
  33.   return pushArray;
  34. }
  35.  
  36. // figure out how to return the push array
  37. // console.log(getUser("altays"));
  38.  
  39.  
  40.  
  41. module.exports = {
  42.   getUser:getUser
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement