title: How to have an async endless loop with Promises
body: <p>I need to have an "endless" while-loop which has promises inside it. Here's some example code:</p>
  
  <pre><code>let noErrorsOccured = true
  
  while (noErrorsOccured){
      someAsyncFunction().then(() =&gt; {
          doSomething();
      }).catch((error) =&gt; {
          console.log("Error: " + error);
          noErrorsOccured = false;
      });
  }
  
  function someAsyncFunction() {
      return new Promise ((resolve, reject) =&gt; {
          setTimeout(() =&gt; {
              const exampleBool = doSomeCheckup();
              if (exampleBool){
                  resolve();
              } else {
                  reject("Checkup failed");
              }
          }, 3000);
      });
  }
  </code></pre>
  
  <p>So this while-loop should run endless, except an error occurs, then the while-loop should stop. How can I achieve this?</p>
  
  <p>I hope you can understand what I mean and thanks in advance.</p>