UNPKG

@prana-w/btw

Version:

btw_cli (btw: by-the-W) is a simple and powerful Command Line Interface (CLI) designed to help you perform various useful tasks directly from your terminal.

26 lines (20 loc) 711 B
import chalk from 'chalk'; import { githubApiUrl } from '../../constants/index.js'; export default async function getGitHubAPIData(username) { try { const url = `${githubApiUrl}/${username}`; const response = await fetch(url); if (!response.ok) { throw new Error('Failed to fetch data from GitHub API'); } const jsonResponse = await response.json(); return { name: jsonResponse?.name || jsonResponse?.login || null, bio: jsonResponse?.bio || null, followers: jsonResponse?.followers || null, following: jsonResponse?.following || null, }; } catch (err) { throw err; } }