0

I use spring boot

I would like to check if an email address alread exist in the system. I created this

@RequestMapping(method = { RequestMethod.HEAD }, value={"/email"})
public ResponseEntity<Boolean> checkEmailexist(@RequestParam String value){
    return ResponseEntity.ok(userService.checkIfEmailExist(value));
}

If i check the result of userService.checkIfEmailExist, depending of the value, I get true or false...

Result from the call it's alway undefined

 $.ajax({
     url: '/email?value=' + usernameValue.value,
     type: 'HEAD',
     success: function (result) {
     console.log(result);
     }
 });
robert trudel
  • 5,283
  • 17
  • 72
  • 124

1 Answers1

0

Its not an answer but rather a set of steps to check that will (hopefully) help you to find a solution:

  1. Make sure your annotations are correct - whether the @RestController annotation is used properly, what is the result, etc.
  2. As a generalization of "1" try to understand whether the issue is on server at all For that run CURL query/use postman - whatever on a deployed server and see the result.
  3. If the issue is on the client side try to understand the status code of the request. I'm not a jquery pro (I understand this is a jquery syntax), but read this question and especially the answer with 'done' method - probably its a better way to work anyway, or at least put a jquery tag on the question so that the relevant people could read it and respond.
Mark Bramnik
  • 39,963
  • 4
  • 57
  • 97