Edits history of script submission #10201 for ' Deletes a specific item (xero)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Xero = {
      token: string;
    };
    /**
     * Deletes a specific item
     *
     */
    export async function main(auth: Xero, ItemID: string, xero_tenant_id: string) {
      const url = new URL(`https://api.xero.com/api.xro/2.0/Items/${ItemID}`);
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Accept: 'application/json',
          "xero-tenant-id": xero_tenant_id,
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 515 days ago