Created
February 10, 2024 07:48
-
-
Save wajeht/b0ae5260ba264f96a01e4b261743607d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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