//native
/**
* Get Task
* Get the full record of a task by its gid. Use `opt_fields` (comma-separated, e.g. `name,assignee.name,custom_fields`) to choose the returned fields.
*/
export async function main(
auth: RT.Asana,
task_gid: string,
opt_fields: string | undefined
) {
const url = new URL(`https://app.asana.com/api/1.0/tasks/${task_gid}`)
if (opt_fields != null && opt_fields !== "") {
url.searchParams.append("opt_fields", opt_fields)
}
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