0

Check Status of a Droplet Destroy with Associated Resources Request

by
Published Dec 20, 2024

To check on the status of a request to destroy a Droplet with its associated resources, send a GET request to the `/v2/droplets/$DROPLET_ID/destroy_with_associated_resources/status` endpoint.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * Check Status of a Droplet Destroy with Associated Resources Request
7
 * To check on the status of a request to destroy a Droplet with its associated
8
resources, send a GET request to the
9
`/v2/droplets/$DROPLET_ID/destroy_with_associated_resources/status` endpoint.
10

11
 */
12
export async function main(auth: Digitalocean, droplet_id: string) {
13
  const url = new URL(
14
    `https://api.digitalocean.com/v2/droplets/${droplet_id}/destroy_with_associated_resources/status`,
15
  );
16

17
  const response = await fetch(url, {
18
    method: "GET",
19
    headers: {
20
      Authorization: "Bearer " + auth.token,
21
    },
22
    body: undefined,
23
  });
24
  if (!response.ok) {
25
    const text = await response.text();
26
    throw new Error(`${response.status} ${text}`);
27
  }
28
  return await response.json();
29
}
30