title: Return value with asynchronous functions in Typescript
body: <p>I have the following TS function: </p>
  
  <pre><code>CheckRegUser(u: User): boolean {
      let b: boolean = true;
      let toSend = {
        email: u.email
      };
      this.http.post("http://localhost:8080/", toSend).subscribe((data: Valid) =&gt; {
        if(!data.validity){
          b = false;
        }
      });
      console.log(b);
      return b;
  }
  </code></pre>
  
  <p>Here I am connecting to an ExpressJS backend and I am getting back a boolean result. This part is working fine, but the problem is that the "return b" statement is executed before that the value of b is changed in "this.http", so b is always true no matter what the response from Express is.</p>
  
  <p>I know that TS and JS are asynchronous and this problem is caused because of that, but I couldn't find the correct method to solve my issue. Any help would be appreciated. </p>