title: Promise resulting in Unexpected identifier
body: <p>This one works:</p>
  
  <pre><code>const phantom   = require('phantom');
  
  async function createBrowser_normal() { 
      var instance = await phantom.create(['--ignore-ssl-errors=yes', '--load-images=no']);
  }
  </code></pre>
  
  <p>Only problem is when I call <code>createBrowser_normal()</code> I cannot be sure if it finished creating the phantom instance or not. </p>
  
  <p>So I try using a promise...</p>
  
  <pre><code>const phantom   = require('phantom');
  
  async function createBrowser_promise() { 
      return new Promise((resolve, reject) =&gt; {
          var instance = await phantom.create(['--ignore-ssl-errors=yes', '--load-images=no']);
          return resolve();
      })
  }
  </code></pre>
  
  <p>The problem is that I now <a href="https://i.stack.imgur.com/6woET.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6woET.jpg" alt="enter image description here"></a>get this error....</p>
  
  <p>Any ideas?</p>
  
  <p>Steves suggestion:</p>
  
  <pre><code>async function createBrowser_normal(cb) {
      console.log("Inside Before call"); 
      instance = await phantom.create(['--ignore-ssl-errors=yes', '--load-images=no']);
      console.log("Inside After call"); 
      return cb(instance);
  }
  
  console.log("Before call"); 
  createBrowser_normal( instance =&gt; { 
      console.log("Got instance", instance); 
      // All code goes here.....
  });
  console.log("After call"); 
  </code></pre>
  
  <p>This gives me a log like this:</p>
  
  <pre><code>Before call
  Inside Before call
  After call
  Inside After call
  Got instance Phantom {....data....}
  </code></pre>
  
  <p>So instead of <code>res = await createBrowser_normal</code> I have to put the code following the instance into the "<code>// All code goes here...</code>"</p>