Skip to content

Instantly share code, notes, and snippets.

@wajeht
Created February 10, 2024 07:48
Show Gist options
  • Save wajeht/b0ae5260ba264f96a01e4b261743607d to your computer and use it in GitHub Desktop.
Save wajeht/b0ae5260ba264f96a01e4b261743607d to your computer and use it in GitHub Desktop.
async function main() {
const headers = {
'Content-Type': 'application/json',
'X-Auth-Key': 'test',
'X-Auth-Email': 'test',
};
const zone = "google.com";
try {
const response = await fetch(`https://api.cloudflare.com/client/v4/zones/${zone}/dns_records`, {
method: 'GET',
headers,
});
const { result } = await response.json();
for (const r of result) {
const deleteResponse = await fetch(`https://api.cloudflare.com/client/v4/zones/${r.zone_id}/dns_records/${r.id}`, {
method: 'DELETE',
headers,
});
const { result: deleteResult } = await deleteResponse.json();
console.log(deleteResult);
}
} catch (error) {
console.log(error.message);
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment