type Github = {
token: string;
};
/**
* Start a codespace for the authenticated user
* Starts a user's codespace.
You must authenticate using an access token with the `codespace` scope to use this endpoint.
GitHub Apps must have write access to the `codespaces_lifecycle_admin` repository permission to use this endpoint.
*/
export async function main(auth: Github, codespace_name: string) {
const url = new URL(
`https://api.github.com/user/codespaces/${codespace_name}/start`
);
const response = await fetch(url, {
method: "POST",
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 367 days ago
type Github = {
token: string;
};
/**
* Start a codespace for the authenticated user
* Starts a user's codespace.
You must authenticate using an access token with the `codespace` scope to use this endpoint.
GitHub Apps must have write access to the `codespaces_lifecycle_admin` repository permission to use this endpoint.
*/
export async function main(auth: Github, codespace_name: string) {
const url = new URL(
`https://api.github.com/user/codespaces/${codespace_name}/start`
);
const response = await fetch(url, {
method: "POST",
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 927 days ago