type Github = {
token: string;
};
/**
* Check if a user can be assigned
* Checks if a user has permission to be assigned to an issue in this repository.
If the `assignee` can be assigned to issues in the repository, a `204` header with no content is returned.
Otherwise a `404` status code is returned.
*/
export async function main(
auth: Github,
owner: string,
repo: string,
assignee: string
) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/assignees/${assignee}`
);
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.text();
}
Submitted by hugo697 367 days ago
type Github = {
token: string;
};
/**
* Check if a user can be assigned
* Checks if a user has permission to be assigned to an issue in this repository.
If the `assignee` can be assigned to issues in the repository, a `204` header with no content is returned.
Otherwise a `404` status code is returned.
*/
export async function main(
auth: Github,
owner: string,
repo: string,
assignee: string
) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/assignees/${assignee}`
);
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.text();
}
Submitted by hugo697 927 days ago