title: How to check if email already exist in angularjs using spring boot
body: <p>I think I almost found a solution to my problem but I still need a bit of tweaking.</p>
  
  <p>I have an <code>@RestController</code> where I do this to check if the user exists or not </p>
  
  <pre><code>@RequestMapping(value = "/email")
  public Boolean getByEmail(@RequestBody String email) {
      String userId;
      try {
          User user = userDao.findByEmail(email);
          userId = String.valueOf(user.getId());
          LOGGER.info(user.toString());
          LOGGER.info(userId);
      }
      catch (Exception ex) {
          LOGGER.info("email does not exist");
          return false;
      }
      LOGGER.info("Email does exist");
      return true;
  }
  </code></pre>
  
  <p>In AngularJs I did something like this: </p>
  
  <pre><code>(function () {
      'use strict';
  
      angular
          .module('app')
          .controller('RegisterController', RegisterController);
  
      RegisterController.$inject = ['UserService', '$http' ];
      function RegisterController(UserService, $http) {
          var vm = this;
  
          vm.register = register;
  
          vm.error="This is a sample Error";
  
          function register() {
  
              testEmail();
              console.log(vm.user)
              console.log(("email must been verified before this"))
  
              //if the testEmail returns false Create a user else give an error
             // vm.dataLoading = true;
             // UserService.Create(vm.user)
  
          }
  
          function testEmail(){
              console.log("Check email")
              console.log(vm.user.email)
              console.log($http.post('/email',vm.user.email))
              return $http.get('/email',vm.user.email)
          }
      }
  
  })();
  </code></pre>
  
  <p>What I basically want to do is find a way that the <code>testEmail</code> function returns <code>true</code> or <code>false</code>?</p>