Spaces:
Running
Running
Download src/services/github/get-user.ts from imspsycho/copilot-api: direct link, hf CLI and curl.
- Browser
- Download file 585 Bytes
-
https://huggingface.co/spaces/imspsycho/copilot-api/resolve/97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-user.ts
- Command line
-
hf download hf://spaces/imspsycho/copilot-api@97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-user.ts
-
curl -L -o get-user.ts https://huggingface.co/spaces/imspsycho/copilot-api/resolve/97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-user.ts
585 Bytes
| import { GITHUB_API_BASE_URL, standardHeaders } from "~/lib/api-config" | |
| import { HTTPError } from "~/lib/error" | |
| import { state } from "~/lib/state" | |
| export async function getGitHubUser() { | |
| const response = await fetch(`${GITHUB_API_BASE_URL}/user`, { | |
| headers: { | |
| authorization: `token ${state.githubToken}`, | |
| ...standardHeaders(), | |
| }, | |
| }) | |
| if (!response.ok) throw new HTTPError("Failed to get GitHub user", response) | |
| return (await response.json()) as GithubUserResponse | |
| } | |
| // Trimmed for the sake of simplicity | |
| interface GithubUserResponse { | |
| login: string | |
| } | |