Skip to content

Instantly share code, notes, and snippets.

@brayn003
Created November 10, 2020 12:40
Show Gist options
  • Save brayn003/cf969125b854ff35dffae9bcff490743 to your computer and use it in GitHub Desktop.
Save brayn003/cf969125b854ff35dffae9bcff490743 to your computer and use it in GitHub Desktop.
One liner code to ping a URL every 3 secs
const URL = 'https://google.com';
const main = () => fetch(URL).then(r => r.status === 200 ? console.log('IS UP', r) : console.log('down', setTimeout(main, 3000)) ).catch(() => setTimeout(main, 3000));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment