type Asana = {
token: string;
};
/**
* Get tasks from a project
* Returns the compact task records for all tasks within the given project, ordered by their priority within the project. Tasks can exist in more than one project at a time.
*/
export async function main(
auth: Asana,
project_gid: string,
completed_since: string | undefined,
opt_pretty: string | undefined,
opt_fields: string | undefined,
limit: string | undefined,
offset: string | undefined
) {
const url = new URL(
`https://app.asana.com/api/1.0/projects/${project_gid}/tasks`
);
for (const [k, v] of [
["completed_since", completed_since],
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
["limit", limit],
["offset", offset],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 203 days ago