title: Fetch call every 2 seconds, but don't want requests to stack up
body: <p>I am trying to make an API call and I want it to repeat every 2 seconds. However I am afraid that if the system doesn't get a request back in 2 seconds, that it will build up requests and keep trying to send them. How can I prevent this?</p>
  
  <p>Here is the action I am trying to <code>fetch</code>:</p>
  
  <pre><code>const getMachineAction = async () =&gt; {
      try {
          const response = await fetch( 'https://localhost:55620/api/machine/');
          if (response.status === 200) {
              console.log("Machine successfully found.");
              const myJson = await response.json(); //extract JSON from the http response
              console.log(myJson);               
          } else {
              console.log("not a 200");
          }
      } catch (err) {
          // catches errors both in fetch and response.json
          console.log(err);
      }
  };
  </code></pre>
  
  <p>And then I call it with a <code>setInterval</code>.</p>
  
  <pre><code>function ping() {
      setInterval(
          getMachineAction(),
          2000
      );        
  }
  </code></pre>
  
  <p>I have thought of doing some promise like structure in the setInterval to make sure that the fetch had worked and completed, but couldn't get it working.</p>