type Github = {
token: string;
};
/**
* Create a fork
* Create a fork for the authenticated user.
**Note**: Forking a Repository happens asynchronously. You may have to wait a short period of time before you can access the git objects. If this takes longer than 5 minutes, be sure to contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api).
*/
export async function main(
auth: Github,
owner: string,
repo: string,
body: {
default_branch_only?: boolean;
name?: string;
organization?: string;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.github.com/repos/${owner}/${repo}/forks`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
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;
};
/**
* Create a fork
* Create a fork for the authenticated user.
**Note**: Forking a Repository happens asynchronously. You may have to wait a short period of time before you can access the git objects. If this takes longer than 5 minutes, be sure to contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api).
*/
export async function main(
auth: Github,
owner: string,
repo: string,
body: {
default_branch_only?: boolean;
name?: string;
organization?: string;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.github.com/repos/${owner}/${repo}/forks`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 927 days ago