type Github = {
token: string;
};
/**
* Get an installation for the authenticated app
* Enables an authenticated GitHub App to find an installation's information using the installation id.
You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint.
*/
export async function main(auth: Github, installation_id: string) {
const url = new URL(
`https://api.github.com/app/installations/${installation_id}`
);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 407 days ago