title: Polling until getting specific result?
body: <p>I am currently trying to add polling to my application using this link <a href="https://davidwalsh.name/javascript-polling" rel="noreferrer">https://davidwalsh.name/javascript-polling</a> (and many others).</p>
  
  <p>I have access to the following already implemented api:</p>
  
  <pre><code>client.get('url')
  // returns Promise with result of getting result from url
  // for the application I am working on,
  //     the URL returns json that looks like the following 
  //     {status: DONE or IN PROGRESS, other values...}
  // when status is DONE other values are what I will use in the application
  
  client.post('url', {data: passAnyDataHere}) 
  // sends a post request with result of sending data to url
  // starts the specific job
  </code></pre>
  
  <p>One of the problems that I have run into is that while trying to adapt the JavaScript Polling code I linked to above, when I find out that the status is DONE, I have no way of returning the result to outside of the Promise.  <strong>Can someone give me tips on how to do this?</strong> (polling until I find a specific value, and then return the value for use later)</p>
  
  <p>Let me give you an example</p>
  
  <pre><code>export default function someFunction() {
      let a = client.get('/status');
      a.then( dataResult =&gt; 
        {
           if (dataResult.status == "DONE") {
              //** want to get other values in dataResult here 
              // and store it somewhere else for use later
           }
        });
      // ***want to work with results here.
      // need some way to get the status of what happened inside the .then(..) part
     //  eventually have to return success or failure and results to the frontend
     // (this part is already done)
   }
  </code></pre>
  
  <p>The base of the code is <a href="https://github.com/erikras/react-redux-universal-hot-example#server-side-data-fetching" rel="noreferrer">https://github.com/erikras/react-redux-universal-hot-example#server-side-data-fetching</a> (uses React.js/Node.js/Redux/etc.)</p>
  
  <p>Any tips/suggestions/help are/is appreciated. Thanks!</p>
  
  <p>Also, the application I am working on does not use JQuery.</p>