0
Delete a project status
One script reply has been approved by the moderators Verified

Deprecated: new integrations should prefer the /status_updates/{status_gid} route.

Deletes a specific, existing project status update.

Returns an empty data record.

Created by hugo697 388 days ago Viewed 8993 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 388 days ago
1
type Asana = {
2
  token: string;
3
};
4
/**
5
 * Delete a project status
6
 * *Deprecated: new integrations should prefer the `/status_updates/{status_gid}` route.*
7

8
Deletes a specific, existing project status update.
9

10
Returns an empty data record.
11
 */
12
export async function main(
13
  auth: Asana,
14
  project_status_gid: string,
15
  opt_pretty: string | undefined,
16
  opt_fields: string | undefined
17
) {
18
  const url = new URL(
19
    `https://app.asana.com/api/1.0/project_statuses/${project_status_gid}`
20
  );
21
  for (const [k, v] of [
22
    ["opt_pretty", opt_pretty],
23
    ["opt_fields", opt_fields],
24
  ]) {
25
    if (v !== undefined && v !== "") {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "DELETE",
31
    headers: {
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42