title: Convert then to async await javascript
body: <p>I am checking the library <a href="https://www.npmjs.com/package/promise-retry" rel="nofollow noreferrer">promise-retry</a></p>
  <p>and I can see that they do the following</p>
  <pre><code>promiseRetry(function (retry, number) {     
      return doSomething()
      .catch(retry);
  })
  .then(function (value) {
      // ..
  }, function (err) {
      // ..
  });
  </code></pre>
  <p>I am using async/await throughout the project, so I have converted it to</p>
  <pre><code>const resp = await promiseRetry((retry, number) =&gt; doSomething().catch(retry));
  </code></pre>
  <p>So this will work to get the value when the retrying works, but what about cases of failure? In the original code they have <code>function(err)</code>, but how can this be replicated? It would have been possible if it was a <code>.catch(err)</code>, but it's more of callback to the <code>then</code> function.</p>