best-army-74344
12/27/2023, 6:43 PMbest-army-74344
12/27/2023, 6:45 PMbest-army-74344
12/27/2023, 6:45 PMbest-army-74344
12/27/2023, 6:48 PMbest-army-74344
12/27/2023, 7:17 PMquick-musician-29561
12/27/2023, 7:38 PMbest-army-74344
12/28/2023, 2:42 PMjolly-policeman-82775
12/28/2023, 2:43 PMjolly-policeman-82775
12/28/2023, 2:43 PMjolly-policeman-82775
12/28/2023, 2:43 PMjolly-policeman-82775
12/28/2023, 2:43 PMquick-musician-29561
12/28/2023, 4:29 PMquick-musician-29561
12/28/2023, 4:39 PMquick-musician-29561
12/28/2023, 5:29 PMquick-musician-29561
12/28/2023, 5:30 PMjs
async function makeAsyncRequest() {
const webhookUrl = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
// REPLACE xxxxxxxx WITH YOUR MAKE.COM WEBHOOK ADDRESS
try {
const response = await axios.post(webhookUrl)
const webhookResponse = JSON.stringify(response.data)
console.log('Log response: ' + webhookResponse)
await deleteAllRecords()
return webhookResponse
} catch (error) {
console.log(error)
}
}
const newString = await makeAsyncRequest()
console.log("newString: " + newString)
const data = JSON.parse(newString)
await createNewRecords(data)
async function deleteAllRecords() {
try {
let allDeleted = false;
while (!allDeleted) {
const data = await Data1Table.findRecords({ selectorName: 'allRecords' });
if (!Array.isArray(data)) {
console.log('No records found.');
allDeleted = true;
} else {
const recordIDs = data.map(record => record.id);
if (recordIDs.length > 0) {
await Data1Table.deleteRecords(recordIDs);
console.log(`${recordIDs.length} records deleted.`);
} else {
allDeleted = true;
console.log('All existing records have been deleted.');
}
}
}
} catch (error) {
console.error("Error while deleting records: ", error);
}
}
async function createNewRecords(sheetsData) {
try {
await Data1Table.createRecords(sheetsData)
} catch (error) {
console.log(error)
}
}
quick-musician-29561
12/28/2023, 5:45 PMjolly-policeman-82775
12/28/2023, 6:08 PMjolly-policeman-82775
12/28/2023, 6:08 PMjolly-policeman-82775
12/28/2023, 6:08 PMjolly-policeman-82775
12/28/2023, 6:08 PMjolly-policeman-82775
12/28/2023, 6:09 PMjolly-policeman-82775
12/28/2023, 6:09 PMquick-musician-29561
12/28/2023, 6:16 PMjolly-policeman-82775
12/28/2023, 6:20 PMjolly-policeman-82775
12/28/2023, 6:20 PMjolly-policeman-82775
12/28/2023, 6:23 PMjolly-policeman-82775
12/28/2023, 6:49 PMjolly-policeman-82775
12/28/2023, 6:49 PMjolly-policeman-82775
12/28/2023, 6:49 PMquick-musician-29561
12/28/2023, 6:50 PMjolly-policeman-82775
12/28/2023, 6:52 PMjolly-policeman-82775
12/28/2023, 6:53 PMjolly-policeman-82775
12/28/2023, 6:54 PMjolly-policeman-82775
12/28/2023, 6:54 PMjolly-policeman-82775
12/28/2023, 6:54 PMjolly-policeman-82775
12/28/2023, 6:56 PMjolly-policeman-82775
12/28/2023, 7:00 PMjolly-policeman-82775
12/28/2023, 7:01 PMjolly-policeman-82775
12/28/2023, 7:01 PMjolly-policeman-82775
12/28/2023, 7:02 PMquick-musician-29561
12/28/2023, 7:11 PMbest-army-74344
12/28/2023, 9:08 PMbest-army-74344
12/28/2023, 9:08 PMquick-musician-29561
12/28/2023, 9:24 PMbest-army-74344
12/29/2023, 1:55 PMbest-army-74344
12/29/2023, 1:56 PMbest-army-74344
12/29/2023, 1:57 PMbest-army-74344
12/29/2023, 2:03 PMbest-army-74344
12/29/2023, 2:03 PMbest-army-74344
12/29/2023, 2:04 PMbest-army-74344
12/29/2023, 2:04 PMquick-musician-29561
12/29/2023, 2:22 PMbest-army-74344
12/29/2023, 2:24 PMquick-musician-29561
12/29/2023, 2:25 PMbest-army-74344
12/29/2023, 2:26 PMbest-army-74344
12/29/2023, 2:27 PMbest-army-74344
01/05/2024, 3:48 PM