//native
/**
* List Comments
* List the open (unresolved) comments on a page or block. Pass a page ID for page-level comments. Paginate with `next_cursor` as `start_cursor`. Needs the read comments capability.
*/
export async function main(
auth: RT.Notion,
block_id: string,
start_cursor: string | undefined,
page_size: number | undefined
) {
const url = new URL("https://api.notion.com/v1/comments")
url.searchParams.append("block_id", block_id)
if (start_cursor !== undefined && start_cursor !== "") {
url.searchParams.append("start_cursor", start_cursor)
}
if (page_size !== undefined) {
url.searchParams.append("page_size", String(page_size))
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
"Notion-Version": "2026-03-11",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 4 hours ago