Edits history of script submission #22335 for ' Delete Record (airtable)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    type Airtable = {
      apiKey: string;
    };
    
    type AirtableTable = {
      baseId: string;
      tableName: string;
    };
    export async function main(
      atCon: Airtable,
      atTable: AirtableTable,
      recordId: string,
    ) {
      const url = `https://api.airtable.com/v0/${atTable.baseId}/${encodeURIComponent(
        atTable.tableName,
      )}/${recordId}`;
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: `Bearer ${atCon.apiKey}`,
          "Content-Type": "application/x-www-form-urlencoded",
        },
      });
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`);
      }
    
      const deleteSingleRecord = await response.json();
    
      return deleteSingleRecord;
    }
    

    Submitted by hugo989 14 days ago