Marks all notifications as "read" for the current user.
1
type Github = {
2
token: string;
3
};
4
/**
5
* Mark notifications as read
6
* Marks all notifications as "read" for the current user.
7
*/
8
export async function main(
9
auth: Github,
10
body: { last_read_at?: string; read?: boolean; [k: string]: unknown }
11
) {
12
const url = new URL(`https://api.github.com/notifications`);
13
14
const response = await fetch(url, {
15
method: "PUT",
16
headers: {
17
"Content-Type": "application/json",
18
Authorization: "Bearer " + auth.token,
19
},
20
body: JSON.stringify(body),
21
});
22
if (!response.ok) {
23
const text = await response.text();
24
throw new Error(`${response.status} ${text}`);
25
}
26
return await response.json();
27
28