'HTTP POST request is being interpreted as OPTIONS in Spring

The UI is calling a Spring Boot API as follows:

  saveData(data: Request): Observable<Response> {
    return this._http.post<Response>(
      "http://localhost:8080/saveData",
      data
    );
  }

Here is the controller method:

@PostMapping(path = "/saveData")
public Mono<Response> saveData(@RequestBody Request request) {
    log.info("saveData() called");
    return service.saveData(request);
}

However, in my request interceptor class, HttpServletRequest.getMethod() shows that this request is an OPTIONS request, not a POST request, and hence, the POST controller method is not being called.

What is going on?



Solution 1:[1]

Well hello Vinay Singla the thing is when you use let you do not have to redeclare it. Otherwise an error will pop and a new let is very similar when you declare variables in python . Code you wrote will cause an error

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ramz