//native
/**
* List Sections
* List the sections of a project, in board column / list order. Pass `next_page.offset` from a response as `offset` to get the next page.
*/
export async function main(
auth: RT.Asana,
project_gid: string,
opt_fields: string | undefined,
limit: number | undefined,
offset: string | undefined
) {
const url = new URL(
`https://app.asana.com/api/1.0/projects/${project_gid}/sections`
)
const params = { opt_fields, limit: limit ?? 100, offset }
for (const [key, value] of Object.entries(params)) {
if (value != null && value !== "") {
url.searchParams.append(key, String(value))
}
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 3 hours ago