Files
open-gsio/scripts/check-analytics.js
geoffsee 33679583af init
2025-05-22 23:14:01 -04:00

32 lines
790 B
JavaScript

const TOKEN = "";
const ACCOUNT_ID = "";
async function showTables() {
const url = `https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/analytics_engine/sql`;
const options = {
method: "POST",
headers: {
Authorization: `Bearer ${TOKEN}`,
"Content-Type": "application/x-www-form-urlencoded",
},
body: "SHOW TABLES",
};
try {
console.log("Sending request to Cloudflare Analytics Engine...");
const response = await fetch(url, options);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log("Response received:", JSON.stringify(data, null, 2));
} catch (error) {
console.error("Error occurred:", error.message);
}
}
showTables();