I'm working with spring boot and angular and I passed as a parameter in get request in the body
@GetMapping("/parAdresse")
public List<Object> parAdresse(@RequestBody String adresse) {
return dis.finddis(adresse) ;
}
How I can do the same in the front?
pieChart(add: string) {
return this.http.get("http://localhost:9095/distri/parAdresse");
}
CodePudding user response:
GET
methods cannot have request body
, you can convert Java action into POST
method.
@PostMapping("/parAdresse")
And then pass the information inside post method body
from angular.
return this.http.post("http://localhost:9095/distri/parAdresse", {
adresse: add
});
CodePudding user response:
backend
@GetMapping("/parAdresse")
public List<Object> parAdresse( @RequestParam String adresse) {
return dis.finddis(adresse) ;
}
front
pieChart(add: string) {
let queryParams = new HttpParams();
queryParams = queryParams.append("adresse","TUNIS");
return this.http.get("http://localhost:9095/distri/parAdresse", {params:queryParams});
}