//native
/**
* Search Issues and Pull Requests
* Search issues and pull requests across GitHub with the search syntax, e.g. 'repo:owner/name is:pr is:open label:bug'. Returns at most 1000 results.
*/
export async function main(
auth: RT.Github,
q: string,
sort: "comments" | "reactions" | "created" | "updated" | undefined,
order: "asc" | "desc" | undefined,
per_page: number = 30,
page: number = 1
) {
const url = new URL("https://api.github.com/search/issues")
for (const [k, v] of Object.entries({ q, sort, order, per_page, page })) {
if (v !== undefined && v !== "") url.searchParams.append(k, String(v))
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago