title: Using await within a Promise
body: <p>There seems something inherently wrong with having to define a Promise's callback as asynchronous:</p>
  
  <pre><code>return new Promise(async (resolve, reject) =&gt; {
    const value = await somethingAsynchronous();
    if (value === something) {
      return resolve('It worked!');
    } else {
      return reject('Nope. Try again.');
    }
  });
  </code></pre>
  
  <p>This is apparently an <a href="https://stackoverflow.com/questions/23803743/what-is-the-explicit-promise-construction-antipattern-and-how-do-i-avoid-it">antipattern</a> and there are coding <a href="https://stackoverflow.com/questions/43036229/using-async-await-inside-new-promise-constructor#43050114">problems which can arise from it</a>. I understand that it becomes easier to fail to catch errors here, even when placing <code>await</code> statements inside <code>try</code>/<code>catch</code> blocks.</p>
  
  <p>My first question is, what's the best way to code something like this, when one wants to forward a Promise with different resolve/reject values? With then/catch? I.e.</p>
  
  <pre><code>return new Promise((resolve, reject) =&gt; {
    somethingAsynchronous().then(value =&gt; {
      if (value === something) {
        return resolve('It worked!');
      } else {
        return reject('Nope. Try again.');
      }
    }); // errors would now be propagated up
  });
  </code></pre>
  
  <p>Or do you just take it out the Promise constructor altogether as suggested <a href="https://stackoverflow.com/questions/43036229/using-async-await-inside-new-promise-constructor#43050114">here</a>?</p>
  
  <pre><code>async function outerFunction() {
    const value = await somethingAsynchronous();
    return new Promise((resolve, reject) =&gt; {
      if (value === something) {
        return resolve('It worked!');
      } else {
        return reject('Nope. Try again.');
      }
    });
  }
  </code></pre>
  
  <p>But what if you have several await statements in the outerFunction(), i.e. a linear code block calling several asynchronous functions. Would you then have to create and return a new Promise every time?</p>
  
  <p>But then how do you account for code such as this?</p>
  
  <pre><code>async function outerFunction() {
    if (someSynchronousCheck()) {
      return 'Nope. Try again.' // another reject case
    }
  
    const value = await somethingAsynchronous();
    // ...
  }
  </code></pre>
  
  <p>I have the feeling that I'm making this more complicated than it should be. I'm trying to avoid nesting callbacks/chaining then/catch blocks without creating more problems in the future.</p>
  
  <p>My final question is, why is the callback passed to a Promise not inherently <code>async</code>? It is already wrapped within a promise and expects the resolve/reject functions to be called asynchronously.</p>