title: Javascript async function gets correct data from API, but only returns "undefined"
body: <p>I looked a bit on the web and couldn't find a good answer to my question, so I'll ask it to you guys.</p>
  
  <p>I have an async function, that gets true/false data from an API, I am able to print the value that I got from the API, but when I return that value, I get an "Undefined" instead.
  I feel like the problem is in the way that I return that variable, but like I said I haven't been able to find an answer, so if someone know how to that would be wonderful.</p>
  
  <p>Here is the function:</p>
  
  <pre><code>const CheckSource = async function(AttId, symbolId){
  
  //creates the get parameters
      var SourceGetParams = Helper.returnGetOptions(`SignalValues/${symbolId}/${AttId}`);
  
  //send the get request and waits for responce
      await Helper.sendRequest(SourceGetParams).then((res, body) =&gt; {
  
  //parses the response, prints the correct value, but returns "undefined"
          var response_body = JSON.parse(res.body);
          var value = response_body.API_Signals[0].RawValue
          console.log(value);
          return Promise.resolve(value);
  
  //error handling
      }, (error) =&gt; {
          console.log('error sending source get request:', error);
          return Promise.reject('There was an error with the fusion request.');
      }).catch((error) =&gt; {
          console.log('Source sendRequest promise error:', error);
          return Promise.reject('There was an internal error sending the request.');
      }); }
  </code></pre>
  
  <p>I have tried to use different methods to return the value (such as 'return value;') but I get the same result. </p>
  
  <p>Here is how I call the function:</p>
  
  <pre><code>CheckSource(&lt;Att_ID string here&gt;, &lt;Symbol_ID string here&gt;).then((data)=&gt;{
      console.log(data)
  });
  </code></pre>
  
  <p>I know this is a question that is often asked, and I tried many of the other answers found here, but got no results.</p>
  
  <p>The answer I get is this:</p>
  
  <pre><code>False //(this is the expected output from the conslole.log() in the async function)
  
  undefined //(this is the console.log() after I called the function)
  </code></pre>
  
  <p>I really appreciate all of you.</p>