type Asana = {
token: string;
};
/**
* Add followers to a task
* Adds followers to a task. Returns an empty data block.
Each task can be associated with zero or more followers in the system.
Requests to add/remove followers, if successful, will return the complete updated task record, described above.
*/
export async function main(
auth: Asana,
task_gid: string,
opt_pretty: string | undefined,
opt_fields: string | undefined,
body: {
data?: { followers: string[]; [k: string]: unknown };
[k: string]: unknown;
}
) {
const url = new URL(
`https://app.asana.com/api/1.0/tasks/${task_gid}/addFollowers`
);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 418 days ago