the_baahubali

Fetch Until Status OK (Beautified)

Jun 18th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. setInterval(function () {
  2.     fetch('https://libra.org/en-US/white-paper/', {})
  3.         .then(function (response) {
  4.             console.log(response.status); // Will show you the status
  5.             if (!response.ok) {
  6.                 throw new Error("HTTP status " + response.status);
  7.             } else {
  8.  
  9.                 location.reload();
  10.             }
  11.  
  12.             return response.json();
  13.         })
  14. }, 1000);
Add Comment
Please, Sign In to add comment