title: How can I save HTTP GET Response to a var using Express (nodejs)?
body: <p>I am using Express in Nodejs in order to make a GET Call. As a response, I get the value that I need, but when I return the value from my function to the main I get undefined. </p>
  
  <pre><code>function getInfo() 
  {
  
        var oauth = getoAuth();
  
        request.get({
          url:'myurl',   
          oauth:oauth, 
          qs:null, 
          json:true
        }, 
            function (e, r, data) {
              body.data = data;
              body.emit('update');
        }); 
  
  
        body.on('update', function () {
          console.log(body.data.issues[0].key);
          return (body.data.issues[0].key);  
        });
  
  }
  </code></pre>
  
  <p>This key is what I need. When I print it in the console I get the correct value, but it doesn't return anything, because it is an async call. How can I return the value? Can I somehow wait for the value using express? I saw on stackoverflow that some people used this body.on('update'... solution, but it didn't work for me. It still saves nothing to a variable. </p>
  
  <h1>EDIT-> the response:</h1>
  
  <pre><code>TESTING: undefined
  THEKEY1
  </code></pre>
  
  <h1>Saving the value at:</h1>
  
  <blockquote>
    <p>var myid= geInfo();</p>
  </blockquote>