-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (23 loc) · 916 Bytes
/
Copy pathscript.js
File metadata and controls
26 lines (23 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
async function getProfile() {
const username = document.getElementById("username").value;
const profileDiv = document.getElementById("profile");
profileDiv.innerHTML = "Loading...";
try {
const response = await fetch(`https://api.github.com/users/${username}`);
if (!response.ok) {
profileDiv.innerHTML = "User not found!";
return;
}
const data = await response.json();
profileDiv.innerHTML = `
<img src="${data.avatar_url}" alt="Avatar" />
<h2>${data.name || data.login}</h2>
<p>📍 ${data.location || 'Unknown'}</p>
<p>💻 Public Repos: ${data.public_repos}</p>
<p>👥 Followers: ${data.followers} | Following: ${data.following}</p>
<a href="${data.html_url}" target="_blank">View Profile 🔗</a>
`;
} catch (error) {
profileDiv.innerHTML = "Something went wrong!";
}
}