Get the profile of the authenticated user.
1
//native
2
3
/**
4
* Get Current User
5
* Get the profile of the authenticated user.
6
*/
7
export async function main(auth: RT.Github) {
8
const response = await fetch("https://api.github.com/user", {
9
headers: {
10
Authorization: `Bearer ${auth.token}`,
11
Accept: "application/vnd.github+json",
12
"X-GitHub-Api-Version": "2022-11-28",
13
},
14
})
15
16
if (!response.ok) {
17
throw new Error(`${response.status} ${await response.text()}`)
18
}
19
20
return await response.json()
21
22