Geek Logbook

Tech sea log book

50projectsIn50days – Day 28: Git Hub profile

Fetching GitHub user information is the core task of this project. This involves interacting with the GitHub API, which is facilitated using the Axios library.

The script is embedded in the HTML as follows:


The HTML itself is initially empty. The creation of the user card and error card is handled by JavaScript functions. The createUserCard function is responsible for generating the user card:

function createUserCard(user) {
    const cardHTML = `
<div class="card">
        <img src="${user.avatar_url}" alt ="${}" class="avatar">
    <div class="user-info">
            <li>${user.followers} <strong>Followers</strong></li>
            <li>${user.following} <strong>Following</strong></li>
            <li>${user.public_repos} <strong>Repos</strong></li>

        <div id="repos"></div>

    main.innerHTML = cardHTML

And this fuction is triggered by the event listener:

form.addEventListener('submit', (e) => {

    const user = search.value

    if(user) {

        search.value = ''

Besides that, the other functions have this relationships:

  • The form.addEventListener triggers the getUser function when the form is submitted.
  • The getUser function makes an API call to fetch user data, then calls createUserCard to display this data.
  • After creating the user card, getUser calls getRepos to fetch and display the user’s repositories.
  • The getRepos function makes another API call and then calls addReposToCard to add the repositories to the card.
  • If any errors occur (either in fetching user data or repositories), createErrorCard is called to display an error message.

You can see the code in this GitHub Repository: GitHub Profile and the demo of the project is here: 28.github_profile

Leave a Reply

Your email address will not be published. Required fields are marked *.