title: Angular 4 wait till http.get execute to continue
body: <p>I'm creating a new register form an app with Ionic and using  ASP.Net(C#) as my API.</p>
  
  <p>I want to check if user exists when the input blur event is activate.</p>
  
  <p><strong><em>The problem is that my code isn't waiting till the server returns a value to continue. 
  What am I doing wrong? Is there a way to do that?</em></strong> </p>
  
  <p><strong>THIS IS MY API CODE:</strong></p>
  
  <pre><code>    [HttpGet]
      public JsonResult verifyEmail(string email)
      {
          var result = Domain.Repository.UserController.Find(email:email);
          if (result != null)
          {
              return Json(new { erro = true, message = "Email already registered!" }, JsonRequestBehavior.AllowGet);
          }
          else
          {
              return Json(new { erro=false,message = "Email is valid!" },JsonRequestBehavior.AllowGet);
          }
      }
  </code></pre>
  
  <p><strong>I CREATED A PROVIDER TO MAKE THE HTTP REQUEST(authProvider):</strong> </p>
  
  <pre><code>   getData(data,func)
      {
          return  new Promise( (resolve,reject)=&gt;{
            this.http.get(apiUrl+func, {params:data})  
            .subscribe(
             res=&gt;{
  
              resolve(res.json());
            },
            async (err)=&gt;{
              reject(err);
  
            });
          });
          }
  </code></pre>
  
  <p><strong>AND HERE IS MY register.ts code:</strong></p>
  
  <pre><code>  validate()
    {
       let validEmail;
       validEmail= this.checkEmail();// I WANT THAT the "validEmail" receives returned value before continue.
  
       return true;
    }
  </code></pre>
  
  <p><strong>AND THE LAST THING IS MY FUNCTION THAT WILL CALL THE PROVIDER:</strong></p>
  
  <pre><code>  checkEmail()
    {
      return this.authService.getData({email:this.model.email},"Account/verifyEmail").then((result)=&gt;{
        let response = &lt;any&gt;{};
        response=result;
        if(response.erro)
        {
          return response.message
        }else
        {
          return true
        }
  
      },(err)=&gt;{
        this.toastService.presentToast("ERROR:"+err,"bottom",undefined,"toast-error");
      });
    }
  </code></pre>
  
  <p>Thanks in advance..</p>