//native
type Digitalocean = {
token: string;
};
/**
* Delete a Domain Record
* To delete a record for a domain, send a DELETE request to
`/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID`.
The record will be deleted and the response status will be a 204. This
indicates a successful request with no body returned.
*/
export async function main(
auth: Digitalocean,
domain_name: string,
domain_record_id: string,
) {
const url = new URL(
`https://api.digitalocean.com/v2/domains/${domain_name}/records/${domain_record_id}`,
);
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 536 days ago