I want to call an api in the spring boot from my angular file For example:profile.service.ts
private baseUrl = '/users';
constructor(private http: HttpClient) {
}
getProfile(id: number): Observable<Object> {
return this.http.get(`${this.baseUrl}` + '/load/' + `${id}`);
}
and java file is : UsersController.java
@RestController
@RequestMapping("/users")
public class UsersController {
@Autowired
private IUsersService iUsersService;
@GetMapping("/list/grid")
public Iterable<UsersViewModel> getAllEmployees() {
return Dozer.mapList(iUsersService.getAll(), UsersViewModel.class);
}
@GetMapping("/load/{id}")
public UsersViewModel getUserById(@PathVariable(value = "id") Long userId){
return Dozer.mapClass(iUsersService.findById(userId).get(),UsersViewModel.class);
}
The server is used for Angular is Apache and spring-boot port is 8090. Please Help me.