Skip to content

Instantly share code, notes, and snippets.

@nomadrat
Created December 3, 2022 15:52
Show Gist options
  • Select an option

  • Save nomadrat/aea5e1303e21d3b6118ff82cbe31455b to your computer and use it in GitHub Desktop.

Select an option

Save nomadrat/aea5e1303e21d3b6118ff82cbe31455b to your computer and use it in GitHub Desktop.
How To Access Cloudflare Worker From The Browser
async function fetchVisitorGEO() {
const response = await fetch('https://empty-bird-5317.your-name.workers.dev/');
const ipInfo = await response.json();
console.log(ipInfo);
}
fetchVisitorGEO();
/** OR */
window.fetch("https://empty-bird-5317.your-name.workers.dev/")
.then(r => r.json()).then((ipInfo)=> console.log(ipInfo));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment