Merge pull request #72 from rafat17/master

Removed null display bug when user profile name or bio was not found in a github profile
This commit is contained in:
Brad Traversy 2021-07-31 11:43:12 -04:00 committed by GitHub
commit 9e59f604e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,14 +28,16 @@ async function getRepos(username) {
} }
function createUserCard(user) { function createUserCard(user) {
const userID = user.name || user.login
const userBio = user.bio ? `<p>${user.bio}</p>` : ''
const cardHTML = ` const cardHTML = `
<div class="card"> <div class="card">
<div> <div>
<img src="${user.avatar_url}" alt="${user.name}" class="avatar"> <img src="${user.avatar_url}" alt="${user.name}" class="avatar">
</div> </div>
<div class="user-info"> <div class="user-info">
<h2>${user.name}</h2> <h2>${userID}</h2>
<p>${user.bio}</p> ${userBio}
<ul> <ul>
<li>${user.followers} <strong>Followers</strong></li> <li>${user.followers} <strong>Followers</strong></li>
<li>${user.following} <strong>Following</strong></li> <li>${user.following} <strong>Following</strong></li>