Reputation: 521
I have the following end point:
@PutMapping(path = "/like/{id}")
public void likeQuestion(@PathVariable("id") String id, @Valid @NotNull @RequestBody Student student) {
logger.info(id, student);
questionService.likeQuestion(id, student);
}
This does not work when I try to send the request from the Angular front end:
likeQuestion(id: string, student: Student) {
console.log(id, student);
return this.http.put(
environment.baseUrl + '/api/questions/like/' + id,
student
);
}
the console still logs out the id
and student
, however, the endpoint does not get logged.
I have another endpoint in the same file that works:
@PutMapping(path = "/edit-comment/{id}")
public void editComment(@PathVariable("id") String id, @Valid @NotNull @RequestBody Comment comment) {
logger.info("Editing comment");
questionService.editComment(id, comment);
}
What could be the potential problem here? Thank you. The request mapping for the controller is @RequestMapping("api/questions")
, which matches the frontend request uri, so I don't know what could be the problem.
I tried checking the network tab in the dev tool but could not find any request being made...
Upvotes: 2
Views: 520
Reputation: 521
It's my bad everyone, I'm sorry. I forgot to subscribe after calling http.
Upvotes: 1
Reputation: 550
maybe Student DTO field's is not valid, and @valid or @notNull fire before controller's log
Upvotes: 5