title: how to turn Child_process.spawn's "Promise" syntax to "async/await" syntax
body: <p>So I have this code and I'm trying to understand the async/await syntax in full depth. The below is the <b>Promise</b> version of the code:</p>
  
  <pre><code>function callToolsPromise(req) {
      return new Promise((resolve, reject) =&gt; {
          let pipshell = 'pipenv';
          let args = ['run', 'tools'];
          req.forEach(arg =&gt; {
              args.push(arg)
          });
          tool = spawn(pipshell, args);
          tool.on('exit', (code) =&gt; {
              if (code !== 0) {
                  tool.stderr.on('data', (data) =&gt; {
                      reject(data);
                  });
              } else {
                  tool.stdout.on ('data', (data) =&gt; {
                      resolve(JSON.parse(data)):
                  });
              }
          });
      })
  }
  </code></pre>
  
  <p>I have some python code I want to execute in tools/__main__.py so that's why I'm calling "pipenv".</p>
  
  <p>Here's my attempt to do write it in <b>async/await</b> way (which actually works):</p>
  
  <pre><code>async function callToolsAsync(req) {
      let pipshell = 'pipenv';
      let args = ['run', 'tools'];
      req.forEach(arg =&gt; {
          args.push(arg)
      });
      let tool = spawn(pipshell, args);
      for await (const data of tool.stdout) {
          return data
      }
  }
  </code></pre>
  
  <p>But all I did was copy and paste from someone's example where I have <code>for await...</code> loop.</p>
  
  <p>Therefore I've been trying to rewrite this same code so that I can actually understand it but I've been failing for days now.</p>
  
  <p>Are there any other ways to write this code with <b>async/await</b> way without using the <code>for await...</code> loop?</p>
  
  <p>Also I have no idea how I can access data except for using the <code>.then</code> syntax:</p>
  
  <pre><code>callToolsAsync(['GET','mailuser'])
  .then(console.log)
  </code></pre>
  
  <p>How else would I access "data" from <code>resolve(data)</code>?</p>
  
  <p>Many thanks.</p>