title: How to get rid of async in function?
body: <p>Let's say I have this code:</p>
  
  <pre><code>const myFunction = async =&gt; {
    const result = await foobar()
  }
  
  const foobar = async () =&gt; {
    const result = {}
    result.foo = await foo()
    result.bar = await bar()
    return result
  }
  </code></pre>
  
  <p>And I want this:</p>
  
  <pre><code>const myFunction = () =&gt; {
    const result = foobar()
  }
  </code></pre>
  
  <p>I tried to wrap <strong>foobar</strong> like this:</p>
  
  <pre><code>const foobar = async () =&gt; {
    return (async () =&gt; {
      const result = {}
      result.foo = await foo()
      result.bar = await bar()
      return result
    })()
  }
  </code></pre>
  
  <p>But this still return a promise</p>
  
  <p>I can't use <strong>.then</strong> in <strong>myFunction</strong>, I need that <strong>foobar</strong> returns the result variable instead a promise.</p>
  
  <p>The problem is that <strong>myFunction</strong> is an async function and it will return a promise but It should return undefine I need to get rid of async in <strong>myFunction</strong>.</p>
  
  <p>Edit: as Sebastian Speitel said, I want to convert <strong>myFunction</strong> to sync</p>
  
  <p>Edit 2: to Shilly, I am using nightwatch for end2end test, nightwatch will call <strong>myFunction()</strong> if there are no errors in the execution of the function it will run perfectly, if there's an error then nightwatch's virtual machines will run forever instead stop, this problem happens if the called function is async.</p>