Edits history of script submission #20021 for ' Delete Source (segment)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Segment = {
      token: string;
      baseUrl: string;
    };
    /**
     * Delete Source
     * Deletes an existing Source.
    
    
    
    • When called, this endpoint may generate the `Source Deleted` event in the audit trail.
          
     */
    export async function main(auth: Segment, sourceId: string) {
      const url = new URL(`${auth.baseUrl}/sources/${sourceId}`);
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago