I'm working on build an web app using Angular and Spring Boot. I am trying to get data from localhost but I get nothing.
This is the json data from the server
And this my service ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {map, catchError} from "rxjs/operators";
import { Observable, throwError } from 'rxjs';
import {Entreprise} from '../modules/entreprise';
@Injectable({
providedIn: 'root'
})
export class EntrepriseService {
constructor(private http:HttpClient) { }
public getEntreprises():Observable<Entreprise>{
return this.http.get<Entreprise>("http://localhost:8080/entreprises/all");
}
}
And this is component ts:
import { Component, OnInit } from '@angular/core';
import { EntrepriseService } from '../services/entreprise.service';
import {Entreprise} from '../modules/entreprise';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
entreprises:Entreprise;
constructor(private entrepriseService:EntrepriseService) { }
public onGetEntreprises(){
return this.entrepriseService.getEntreprises().
subscribe(data =>{
this.entreprises = data;
console.log(data);
});
}
ngOnInit(): void {
}
}
And this is the html template
<h4>entreprises</h4>
<button (click)="onGetEntreprises()">get </button>
<p *ngFor="let ee of entreprises">{{ee.content.name}}</p>
And this is the error I get when I click on the button

