I have this code with node to update the ip and I can’t do it
const axios = require(‘axios’);
const email = ‘your-email’;
const apiKey = ‘your-api-key’;
const zoneId = ‘your-zone-id’;
const recordId = ‘your-record-id’;
async function updateDNSRecord() {
const response = await axios.get(“https://api.ipify.org?format=json”);
const json = response.data;
const url = https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records/${recordId}
;
try {
const response = await axios({
method: 'put',
url: url,
headers: {
'Content-Type': 'application/json',
'X-Auth-Email': email,
'X-Auth-Key': apiKey,
},
data: {
type: 'A',
name: 'subdomain',
content: json.ip,
ttl: 120
}
});
console.log(response.data);
} catch (error) {
console.log(error.response.data);
}
}
updateDNSRecord();