title: Angular 6: unable to make http request
body: <p>In my angular application, I am trying to make the http post request to the spring restful API.. but I could not succeed.. I am not getting any error response in the browser console..</p>
  
  <p>My angular code is,</p>
  
  <pre><code>addToCart(productId: number, quantity: number) {
      const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
      console.log("--------order.service.ts----------addToCart()-------productId:"+productId+":------quantity:"+quantity);
       this.http.post('http://localhost:8080/order/addtocart', 
                '{ "dealerId": 9, "createdBy": "-1", "productId": productId, "quantity": quantity}', 
                {headers: headers})
                .pipe(catchError(this.errorHandlerService.handleError));
      }
  </code></pre>
  
  <p>Spring restful API:</p>
  
  <pre><code>package com.wocs.rest.controller;
  
  import java.io.IOException;
  import java.util.Map;
  
  import org.apache.log4j.Logger;
  import org.springframework.beans.factory.annotation.Autowired;
  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 com.fasterxml.jackson.core.JsonParseException;
  import com.fasterxml.jackson.core.type.TypeReference;
  import com.fasterxml.jackson.databind.JsonMappingException;
  import com.fasterxml.jackson.databind.ObjectMapper;
  import com.wocs.services.common.ServiceException;
  import com.wocs.services.order.iface.OrderServiceIface;
  import com.wocs.services.userrole.model.User;
  
  @RestController()
  @RequestMapping("/order")
  public class OrderController {
  
      static Logger logger = Logger.getLogger(OrderController.class);
  
      @Autowired
      private OrderServiceIface orderService;
  
      public void setOrderService(OrderServiceIface orderService) {
          this.orderService = orderService;
      }
  
      @RequestMapping(value = "/addtocart", method = RequestMethod.POST, consumes = "text/plain")
      public void addToCart(@RequestBody String stringRequestBody) throws JsonParseException, JsonMappingException, IOException, ServiceException
      {
          logger.info("addtocart:"+stringRequestBody);
          Map&lt;String, Object&gt; jsonMap = new ObjectMapper().readValue(stringRequestBody,
              new TypeReference&lt;Map&lt;String,Object&gt;&gt;(){});
  
           orderService.addToCart((Integer)jsonMap.get("dealerId"), (String) jsonMap.get("createdBy"), (Integer)jsonMap.get("productId"), (Integer)jsonMap.get("quantity"));
      }
  
  }
  </code></pre>
  
  <p>Browser console:</p>
  
  <p><a href="https://i.stack.imgur.com/CqqMt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CqqMt.png" alt="enter image description here"></a></p>
  
  <p>Any help would be appreciated.. Thanks in advance..</p>