type Asana = {
token: string;
};
/**
* Remove followers from a task
* Removes each of the specified followers from the task if they are following. Returns the complete, updated record for the affected task.
*/
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}/removeFollowers`
);
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 388 days ago