-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtest5.js
More file actions
31 lines (26 loc) · 943 Bytes
/
Copy pathtest5.js
File metadata and controls
31 lines (26 loc) · 943 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
27
28
29
30
31
import readline from 'readline';
async function fetchGitHubUser(username) {
try {
const response = await fetch(`https://api.github.com/users/${username}`);
if (!response.ok) {
throw new Error(`User "${username}" not found!`);
}
const data = await response.json();
console.log("Username:", data.login);
console.log("Name:", data.name || "No name provided");
console.log("Public Repos:", data.public_repos);
console.log("Followers:", data.followers);
console.log("Profile URL:", data.html_url);
console.log("---------------------------");
} catch (error) {
console.error("Error fetching data:", error.message);
}
}
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question("Enter GitHub username: ", async (username) => {
await fetchGitHubUser(username);
rl.close();
});