title: How to return a value within a function with an event listener?
body: <p>I have a function like so:</p>
  <pre class="lang-js prettyprint-override"><code>async function websocketRequest() {
    ws.onmessage(message =&gt; {
       // do some validation with message
       // how to return message here?
    })
  } 
  </code></pre>
  <p>What I'm trying to accomplish is make a function that sends a websocket request to the server with a unique request id, when the server responds, it should use the request id to match the response with the request.</p>