Deletes an order risk for an order

Deletes an order risk for an order Note You cannot delete an order risk that was created by another application.

Script shopify Verified

by hugo697 ยท 11/8/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 396 days ago
1
type Shopify = {
2
  token: string;
3
  store_name: string;
4
};
5
/**
6
 * Deletes an order risk for an order
7
 * Deletes an order risk for an order   Note You cannot delete an order risk that was created by another application.
8
 */
9
export async function main(
10
  auth: Shopify,
11
  api_version: string = "2023-10",
12
  order_id: string,
13
  risk_id: string
14
) {
15
  const url = new URL(
16
    `https://${auth.store_name}.myshopify.com/admin/api/${api_version}/orders/${order_id}/risks/${risk_id}.json`
17
  );
18

19
  const response = await fetch(url, {
20
    method: "DELETE",
21
    headers: {
22
      "X-Shopify-Access-Token": auth.token,
23
    },
24
    body: undefined,
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.json();
31
}
32