type Github = {
token: string;
};
/**
* Set a thread subscription
* If you are watching a repository, you receive notifications for all threads by default.
*/
export async function main(
auth: Github,
thread_id: string,
body: { ignored?: boolean; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/notifications/threads/${thread_id}/subscription`
);
const response = await fetch(url, {
method: "PUT",
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;
};
/**
* Set a thread subscription
* If you are watching a repository, you receive notifications for all threads by default.
*/
export async function main(
auth: Github,
thread_id: string,
body: { ignored?: boolean; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/notifications/threads/${thread_id}/subscription`
);
const response = await fetch(url, {
method: "PUT",
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