mirror of
https://github.com/tiennm99/is-a-good-dev.git
synced 2026-10-14 10:18:41 +00:00
Update addRecords.js
This commit is contained in:
1 parent
bce758bc85
commit
ba41551125
1 file changed
+23
@@ -1,3 +1,26 @@
|
||||
const fetch = require('node-fetch');
|
||||
const getJSON = require('../utils/getJSON.js');
|
||||
const data = getJSON(process.env.FILES);
|
||||
|
||||
async function addRecord(type, name, value) {
|
||||
|
||||
const response = await fetch(`https://api.is-a-good.dev/api/is-a-good-dev/zones/add?apiKey=${process.env.API_KEY}&type=${type}&name=${name}&content=${value}`);
|
||||
const data = await response.json();
|
||||
return data
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const records = Object.keys(data.target)
|
||||
for (const i in records) {
|
||||
recordType = records[i]
|
||||
name = data.target[recordType].name;
|
||||
value = data.target[recordType].value;
|
||||
const result = await addRecord(type, name, value);
|
||||
console.log(result);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Error adding records")
|
||||
console.log(e)
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user