Created
September 29, 2023 14:11
-
-
Save vanodevium/abfb765646c47f447f43f190f815802c to your computer and use it in GitHub Desktop.
Fetch data as object from Cloudflare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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