-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (24 loc) · 948 Bytes
/
index.js
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
//npm install axios readline
const axios = require('axios');
const readline = require('readline');
// Create an interface for user input
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// Ask for the GitHub username
rl.question('\n[-] Enter the GitHub username: ', async (username) => {
try {
// Fetch user information
const userResponse = await axios.get(`https://api.github.com/users/${username}`);
console.log('User Info:', JSON.stringify(userResponse.data, null, 2));
// Fetch user's repositories
const reposResponse = await axios.get(`https://api.github.com/users/${username}/repos`);
console.log('Repositories:', JSON.stringify(reposResponse.data, null, 2));
} catch (error) {
console.error('Error fetching data from GitHub:', error.message);
} finally {
// Close the readline interface
rl.close();
}
});