Garmaine Staff asked 1 year ago

i'm working on build an web app using angular and spring boot.. so i try to get data from localhost but i get nothing..

  • this is the json data from the server enter image description here

  • 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';

  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';

  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']

export class LoginComponent implements OnInit {


  constructor(private entrepriseService:EntrepriseService) { }

  public onGetEntreprises(){

    return this.entrepriseService.getEntreprises().
   subscribe(data =>{
      this.entreprises = data;



  ngOnInit(): void {


  • and this is the html template
<button (click)="onGetEntreprises()">get </button>

<p *ngFor="let ee of entreprises">{{}}</p>

  • and this is ** the error** i get when i click on the button

enter image description here

i hope someone can help me because i have to finish this project as soon as possible .