//native
/**
* Get all categories
* Get all categories within a section of your ReadMe project.
The sorting of this data is dependent upon the order of the categories in your sidebar.
>📘
> This route is only available to projects that are using [ReadMe Refactored](https://docs.readme.com/main/docs/welcome-to-readme-refactored).
*/
export async function main(auth: RT.Readme, section: 'guides' | 'reference', branch: string) {
const url = new URL(`https://api.readme.com/v2/branches/${branch}/categories/${section}`)
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago