title: Java Spring 4.0 responds with status code 200 but angular Js execute(to incorrect login) the error block of the response
body: <p><a href="https://i.stack.imgur.com/XPmaa.png" rel="nofollow noreferrer">enter image description here</a>Angular js-1 (loginCtrl) : Angular doesn't reflect spring response, I do not understand what could be the problem...may you please assist, by the way am new to angular and spring RestFul-ws </p>
  
  <pre><code>app.controller('loginCtrl', function($scope,$http,$window){  
  
              $scope.login = function(email,password) {
              var myData = {
              email: $scope.email,
              password: $scope.password
              };
  
              $http.post(customerURL,JSON.stringify(myData)).then(function(response){
                  if(response.data)
                  console.log(response.data);
                  $scope.msg = "SUCCESSFULLY LOGGED IN";
                  $scope.status = response.status;
                  $scope.statusText = response.statusText;
                  console.log($scope.msg);    
                  },function(response){
                   //console.log(response.status);
  
                  $scope.msg = "ERROR LOGIN IN";
  
                 console.log($scope.msg);
  
  
              });
          };                                                                                                       
         });
  </code></pre>
  
  <p>Java Spring 4.0 : find email and hashed password(using checkpw) correctly ...</p>
  
  <pre><code> @RequestMapping(value="",method = RequestMethod.POST)
       public ResponseEntity LoginCustomer(@RequestBody String json) throws CustomerNotFoundException
       {
         try {
               ObjectMapper mapper = new ObjectMapper();
               final JsonNode data = mapper.readTree(json);
  
               String email = data.get("email").asText();
               String password = data.get("password").asText();
  
  
               if(services.findByName(email)  != null &amp;&amp; services.findByPw(password) != null){
               logger.info("received correct user details in :json String " + json);
               System.out.println("Successfull!!");
               return  new ResponseEntity(HttpStatus.OK);
  
               }else{
                System.out.println("Error!!");
                return  new ResponseEntity(HttpStatus.BAD_REQUEST);
               }
          } catch (IOException ex){
           throw new RuntimeException(ex);
          }
  
       }
  </code></pre>
  
  <p>my current customer controller... </p>
  
  <pre><code>/*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
  package com.product.Controller;
  
  import com.product.Exceptions.CustomerNotFoundException;
  import com.product.Services.CustomerServices;
  import com.product.Product.Customer;
  
  import com.fasterxml.jackson.databind.JsonNode;
  import com.fasterxml.jackson.databind.ObjectMapper;
  
  
  import java.io.IOException;
  import java.io.Serializable;
  import java.util.List;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.ResponseEntity;
  import org.springframework.security.crypto.bcrypt.BCrypt;
  import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RestController;
  import org.springframework.web.servlet.ModelAndView;
  
  /*
   *
   * @author HP
   */
  @RestController
  @RequestMapping("/customer")
  public class CustomerController{
      /////////members ////////////////////////////////////////////////////////////////////////////////////
       private static final Logger logger = LoggerFactory.getLogger(CustomerController.class);           //
       @Autowired                                                                                        //
       private CustomerServices services; 
       private BCryptPasswordEncoder pe;//
       ///////////////////////////////////////////////////////////////////////////////////////////////////
  
       @RequestMapping(value="",method = RequestMethod.PUT)
       public ResponseEntity createCustomer(@RequestBody String json) throws CustomerNotFoundException
       {
         try {
               ObjectMapper mapper = new ObjectMapper();
               final JsonNode data = mapper.readTree(json);
               logger.info("recived json String " + json);
               String email = data.get("email").asText();
               String password = data.get("password").asText();
               String firstname = data.get("firstname").asText();
               String surname = data.get("surname").asText();
  
               //brypt hashing 
               String pw_hash = BCrypt.hashpw(password,BCrypt.gensalt(10));
  
                Customer c = new Customer(firstname, surname, email, pw_hash);
  
  
               ///////create customer /////////
               services.createCustomer(c);
               ///return if try was succesful
               //loginService.createLogin(u);
              return  new ResponseEntity(HttpStatus.CREATED);
  
          } catch (IOException ex){
           throw new RuntimeException(ex);
          }
  
       }
  
       @RequestMapping(value="",method = RequestMethod.POST)
       public ResponseEntity LoginCustomer(@RequestBody String json) throws CustomerNotFoundException
       {
         try {
               ObjectMapper mapper = new ObjectMapper();
               final JsonNode data = mapper.readTree(json);
  
               String email = data.get("email").asText();
               String password = data.get("password").asText();
  
  
               if(services.findByName(email)  != null &amp;&amp; services.findByPw(password) != null){
               logger.info("received correct user details in :json String " + json);
               System.out.println("Successfull!!");
               return  new ResponseEntity(HttpStatus.OK);
  
               }else{
                System.out.println("Error!!");
                return  new ResponseEntity(HttpStatus.BAD_REQUEST);
               }
          } catch (IOException ex){
           throw new RuntimeException(ex);
          }
  
       }
  
  
  
        @RequestMapping(value = "", method = RequestMethod.GET)
      public ResponseEntity&lt;List&lt;Customer&gt;&gt; getAllCustomers() {
  
          List&lt;Customer&gt; customerList = services.getCustomerList();
          if(customerList != null) {
              return new ResponseEntity&lt;&gt;(customerList, HttpStatus.OK);
          }else{
              return  new ResponseEntity&lt;&gt;(HttpStatus.BAD_REQUEST);
          }
      }
  
      @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
      public ResponseEntity&lt;CustomerController&gt; Delete(@PathVariable long id) throws CustomerNotFoundException {
      services.DeleteCustomer(id);
      return  new ResponseEntity&lt;&gt;(HttpStatus.BAD_REQUEST);
      }
  }
  </code></pre>