Edits history of script submission #12108 for ' Delete a Glossary (deepl)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Deepl = {
      apiKey: string;
      baseUrl: string;
    };
    /**
     * Delete a Glossary
     * Deletes the specified glossary.
     */
    export async function main(auth: Deepl, glossary_id: string) {
      const url = new URL(`${auth.baseUrl}/v2/glossaries/${glossary_id}`);
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "DeepL-Auth-Key " + auth.apiKey,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 428 days ago