title: Passing Variables Through a Promise Chain
body: <p>Is there a better way to do this?</p>
  
  <pre><code>let foo;
  return functionA().then(result =&gt; {
    foo = result;
    return functionB();
  }).then(bar =&gt; {
    return functionC(foo, bar);
  });
  </code></pre>
  
  <p>Notice that the result of <code>functionA</code> is required input to <code>functionC</code>. Using a  variable outside the promise scope works fine, but it feels kinda icky. Is there a clean idiomatic way to do this?</p>
  
  <p>Please note that I do not have the opportunity to change the API of any of the functions I am calling.</p>