How return a value from an async/await function : <p>I am trying to write a reusable function that doesn't return until it has resolved promise from a mongodb query.
I can nearly achieve this using a IIFE function but seem unable to access the resolved value before I return from the function. In the snippet below i can print variable d to the console but i cant make it accessible outside the iffe and thus cannot return the result. </p>

<p>In the example below the first console.log returns the correct result but the second returns a pending promise.
Any suggestions as to how to make this work or alternative methods will be much appreciated.</p>

<pre><code>function getDNInfo (party){
  var result;
  result= (async () =&gt; { result = await mongo.findOne({DN:party.user_Number}, "BWUsers")
    .then(
            (d)=&gt;{
              console.log(d)
              result=d;
            }"
        )}
   )();
   console.log(result)
   return result;

  }
</code></pre>
