title: How to return to parent function in JavaScript
body: <p>I have the following function at the moment, and I want to return <code>"aaa"</code> to the parent function (getStream), this is the code I have atm:</p>
  
  <pre class="lang-js prettyprint-override"><code>module.exports.getStream = (figure) =&gt; {
      plotly.plot(figure, imgOpts, function(err, stream) {
          if (err) {
              console.log(err);
              return "error";
          }
  
          return "aaa";
      });
  };
  </code></pre>
  
  <p>Right now, however, it returns <code>undefined</code>. What's the best solution to solve that problem?</p>