diff --git a/func.js b/func.js deleted file mode 100644 index 2b0955b..0000000 --- a/func.js +++ /dev/null @@ -1,42 +0,0 @@ -document.querySelector(".data").style.display = "none"; -document.getElementById("start").addEventListener("click", async function () { - console.log("UserInfo function called"); - const username = document.getElementById('username').value; - - if (!username) { - alert('Please enter a valid GitHub username.'); - return; - } - - try { - const response = await fetch(`https://api.github.com/users/${username}`); - const userData = await response.json(); - - if (response.ok) { - displayUserInfo(userData); - } else { - displayError(userData.message); - } - } catch (error) { - displayError('An error occurred while fetching data.'); - } -}); - -function displayUserInfo(user) { - document.querySelector(".details").style.display = "none"; - document.querySelector(".data").style.display = "block"; - const resultDiv = document.getElementById('data'); - resultDiv.innerHTML = ` - Avatar -

${user.login}

-

Name: ${user.name || 'Not available'}

-

Public Repositories: ${user.public_repos}

-

Followers: ${user.followers}

-

Location: ${user.location || 'Not available'}

-

Following: ${user.following}

` -} - -function displayError(message) { - const resultDiv = document.getElementById('data'); - resultDiv.innerHTML = `

Error: ${message}

`; -}