title: How to retry API once a specific field of response is ready?
body: <p>One of the fields of the responses of the API I try to call only be ready after a period of time.</p>
  <p>How can I get the field once it is ready to fetch?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const apiState = Date.now();
  const callApi = () =&gt; Promise.resolve({
    field: "xxx",
    asyncField: Date.now() - apiState &gt; 10000 ? "aaa" : undefined
  });
  
  async function waitForApiReady() {
    const response = await callApi();
    console.log({ response });
    //response.asyncField is undefined at this moment, but it will ready after 10secs or later.
    return response.asyncField;
  }
  
  waitForApiReady().then(console.log).catch(console.log);</code></pre>
  </div>
  </div>
  </p>