-
-
Notifications
You must be signed in to change notification settings - Fork 595
Expand file tree
/
Copy pathget-user.ts
More file actions
21 lines (17 loc) · 586 Bytes
/
get-user.ts
File metadata and controls
21 lines (17 loc) · 586 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { githubApiBaseUrl, standardHeaders } from "~/lib/api-config"
import { HTTPError } from "~/lib/error"
import { state } from "~/lib/state"
export async function getGitHubUser() {
const response = await fetch(`${githubApiBaseUrl(state)}/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
}