title: Send POST request to server, Server's response is null, Angular - Spring-boot
body: <p>I want to send a POST request with my angular client to my spring-boot server.</p>
  
  <p>The server receive sucessfully the data and anwser with 200 Code and body with a string that contains "ok".</p>
  
  <p>But the client receive null as anwser.</p>
  
  <p>Angular code :</p>
  
  <pre class="lang-js prettyprint-override"><code>httpOptions = {
          headers: new HttpHeaders({
              'Content-Type': 'application/json',
              'Accept': 'application/json',
              'Access-Control-Allow-Methods': 'POST, GET'
          })
      };
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>this.http.post(this.URL, JSON.stringify(this.alert), this.httpOptions)
              .subscribe((result: string) =&gt; {
                  if (result == null || result === 'error') {
                      //if fail;
                  } else {
                      //if success;
                  }
                  console.log('result :' + result);
              })
  </code></pre>
  
  <p>Spring-boot code : </p>
  
  <pre class="lang-java prettyprint-override"><code>    @CrossOrigin(origins = "http://localhost:9000")
      @PostMapping(value = "/url")
      public ResponseEntity objDataController(@RequestBody ObjData objData) {
          HttpHeaders resHeader = new HttpHeaders();
  
          resHeader.set("origin", "http://localhost:8080");
          resHeader.set("Content-Type", "application/json");
          resHeader.set("Accept", "application/json");
  
          //some code
  
          return ResponseEntity.ok()
                  .headers(resHeader)
                  .body("ok");
      }
  </code></pre>
  
  <p>At console.log get : 
  <code>result :null</code></p>
  
  <p>Thanks</p>