title: How to create a while loop with delay in nodejs
body: <p>Let's say I have this pseudo code:</p>
  
  <pre><code>var STATUS = '';
  while (STATUS !== "SUCCEEDED") {
      STATUS = getStatus();
      anotherFunc();
      delay(3s);
  }
  </code></pre>
  
  <p>The goal of this code is to keep calling an api to check a status of something, the api returns IN_PROGRESS or SUCCEEDED. So I want the while loop to keep calling <code>getStatus()</code> to get the value of STATUS and break the loop when it is SUCCEEDED. I also want to put a delay between each iteration.</p>
  
  <p>This can't be done easily with Nodejs. So please help me out.</p>