| 28 | } |
| 29 | |
| 30 | function createUserCard(user) { |
| 31 | const userID = user.name || user.login |
| 32 | const userBio = user.bio ? `<p>${user.bio}</p>` : '' |
| 33 | const cardHTML = ` |
| 34 | <div class="card"> |
| 35 | <div> |
| 36 | <img src="${user.avatar_url}" alt="${user.name}" class="avatar"> |
| 37 | </div> |
| 38 | <div class="user-info"> |
| 39 | <h2>${userID}</h2> |
| 40 | ${userBio} |
| 41 | <ul> |
| 42 | <li>${user.followers} <strong>Followers</strong></li> |
| 43 | <li>${user.following} <strong>Following</strong></li> |
| 44 | <li>${user.public_repos} <strong>Repos</strong></li> |
| 45 | </ul> |
| 46 | |
| 47 | <div id="repos"></div> |
| 48 | </div> |
| 49 | </div> |
| 50 | ` |
| 51 | main.innerHTML = cardHTML |
| 52 | |
| 53 | } |
| 54 | |
| 55 | function createErrorCard(msg) { |
| 56 | const cardHTML = ` |