Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions GitHubCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(replacing the placeholder with your Github name):
https://api.github.com/users/<your name>
*/

import axios from 'axios';
// console.log(axios.get('https://api.github.com/users/rberry16'))
/*
STEP 2: Inspect and study the data coming back, this is YOUR
github info! You will need to understand the structure of this
Expand All @@ -28,7 +29,7 @@
user, and adding that card to the DOM.
*/

const followersArray = [];
const followersArray = ['rberry16', 'tetondan', 'dustinmyers', 'justsml', 'luishrd', 'bigknell'];

/*
STEP 3: Create a function that accepts a single object as its only argument.
Expand All @@ -49,7 +50,61 @@ const followersArray = [];
</div>
</div>
*/
function cardMaker(user) {
const card = document.createElement('div');
const cardImg = document.createElement('img');
const cardInfo = document.createElement('div');
const name = document.createElement('h3');
const username = document.createElement('p');
const location = document.createElement('p');
const profile = document.createElement('p');
const address = document.createElement('a');
const followers = document.createElement('p');
const following = document.createElement('p');
const bio = document.createElement('p');

card.appendChild(cardImg);
card.appendChild(cardInfo);
cardInfo.appendChild(name);
cardInfo.appendChild(username);
cardInfo.appendChild(location);
cardInfo.appendChild(profile);
profile.appendChild(address);
cardInfo.appendChild(followers);
cardInfo.appendChild(following);
cardInfo.appendChild(bio);


card.classList.add('card');
cardInfo.classList.add('card-info');
name.classList.add('name');
username.classList.add('username');

cardImg.src = user.avatar_url;
name.textContent = user.name;
username.textContent = user.login;
location.textContent = user.location;
profile.textContent = `Profile`;
address.href = user.url
followers.textContent = `Followers: ${user.followers}`;
following.textContent = `Following: ${user.following}`;
bio.textContent = user.bio;

return card;

}


function makeCards(username) {
axios.get(`https://api.github.com/users/${username}`)
.then(res => {
document.querySelector('.cards').appendChild(cardMaker(res.data));
})
}

for (let i = 0; i < followersArray.length; i++) {
makeCards(followersArray[i]);
}
/*
List of LS Instructors Github username's:
tetondan
Expand Down
43 changes: 43 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
"eslint": "^8.10.0",
"parcel-bundler": "^1.12.4"
},
"dependencies": {}
"dependencies": {
"axios": "^0.26.1"
}
}