I have encountered an issue while testing my JPA delete method using Postman. Although the test returns a 200 response, it fails to actually delete records from my database.
Repository:
@Repository
public interface TeamUserRepository extends JpaRepository<TeamUser, Long> {
void deleteByUserId(Integer userId);
}
Service:
public void removeTeamUser(Integer userId) {
teamUserRepository.deleteByUserId(userId);
}
Controller:
@DeleteMapping(value = "/{teamId}/users/{userId}")
public void removeUserFromTeam(Integer userId) {
teamService.removeTeamUser(userId);
}
Typescript:
export const removeUserFromTeam = (teamId: number | string, userId: number | string) =>
axios.delete(`http://localhost:8080/api/v1/team/${teamId}/users/${userId}`)