Advertisement
Guest User

Untitled

a guest
May 1st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. @RequestMapping(value = "/signup", method = RequestMethod.POST)
  2. public ResponseEntity<String> signup(@RequestBody Candidat candidat) throws Exception {
  3. String response = candidatMetier.signup(candidat);
  4.  
  5. if (response.equals("username_already_exists"))
  6. return new ResponseEntity<>("User name already exists", HttpStatus.CONFLICT);
  7. else if (response.equals("email_already_exists"))
  8. return new ResponseEntity<>("Email already exists", HttpStatus.CONFLICT);
  9. else if (response.equals("mailer_error"))
  10. return new ResponseEntity<>("Cannot signup, reason : Email service is down",
  11. HttpStatus.SERVICE_UNAVAILABLE);
  12. else
  13. return new ResponseEntity<>("Signup successful", HttpStatus.OK);
  14. }
  15.  
  16. .factory('signupService',['$resource',
  17. function ($resource) {
  18. return $resource('http://localhost:8080/signup', {}, {
  19. signup: { method: "POST"}
  20. });
  21.  
  22. }])
  23.  
  24. signupService.signup({
  25. type: "UC",
  26. username: $scope.user.username,
  27. password: $scope.user.password,
  28. email: $scope.user.email
  29. }).$promise.then(function(data){
  30. console.log(data);
  31. }).finally(function(){
  32. $scope.loading = false;
  33. $scope.signupSucceful = true;
  34. console.log('finished');
  35. });
  36.  
  37. SyntaxError: Unexpected token S in JSON at position 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement