//native
/**
* List Organizations
* List the organizations the authenticated user belongs to. Private memberships need the read:org scope (classic tokens).
*/
export async function main(
auth: RT.Github,
per_page: number = 30,
page: number = 1
) {
const url = new URL("https://api.github.com/user/orgs")
url.searchParams.append("per_page", String(per_page))
url.searchParams.append("page", String(page))
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago