I'm using the new angle library to make requests, HttpClient
. Along with the angled 4+ I am using here in the enterprise for the backend , Java with Spring (boot).
HttpParams
, used with HttpClient
to pass parameters, does not replace of the variables and thus the backend deny the request.
URL backend (Java): controller/obterByCodOne/{codOne}/codTwo/{codTwo}
Ex: URL frontend (Angular): http://localhost:8080/controller/obterByCodOne/:codOne/codTwo/:codTwo
Code:
let params = new HttpParams()
.set('codOne', codOne)
.set('codTwo', codTwo);
Result (wrong): http://localhost:8080/controller/obterByCodOne/:codOne/codTwo/:codTwo?codOne=valueA&codTwo=valueB
HttpParams
is not replacing the variable, but concatenating.
In other AngularJS projects, the value was usually replaced with $resource
. Instead of having to concatenate chunks of URLs with the variables until you get to a final result.
Anyway ... I'm in this mess. Either I'm not understanding the use of HttpParams or I'm not sure how to use it.