Skip to content

Instantly share code, notes, and snippets.

@vanodevium
Created September 29, 2023 14:11
Show Gist options
  • Save vanodevium/abfb765646c47f447f43f190f815802c to your computer and use it in GitHub Desktop.
Save vanodevium/abfb765646c47f447f43f190f815802c to your computer and use it in GitHub Desktop.
Fetch data as object from Cloudflare
(async () => {
const fetchCloudFlare = async () => {
return fetch('https://www.cloudflare.com/cdn-cgi/trace')
.then(response => response.text())
.then(data => {
return data
.trim()
.split("\n")
.reduce(function(obj, pair) {
pair = pair.split("=");
obj[pair[0]] = pair[1];
return obj;
}, {});
});
}
console.log(await fetchCloudFlare())
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment