0

today i create my first project in angular with json-server, when i start my application with ng serve, i get this error :

src/app/services/products.service.ts:22:26 - error TS2339: Property 'host' does not exist on type '{}'.
22   let host = environment.host;

i try many solutions like restart server or ng build but without any result project details : angular version : 15.2.8 CLI : 15.2.7 Node : 18.15.0 npm : 9.5 thank you to take a look at my problem.

products.service.ts :

getSelectedProducts():Observable<Product[]>{
  let host = environment.host;
  return this.http.get<Product[]>(host+"/products?selected=true");
}

environment.ts :

export const environment = {
  production : false,
  host : "http://localhost:3000",
};

products.component.ts:

products$ : Observable <Product[]> | null=null;

constructor(private productService : ProductsService) {
}

  onGetAllProducts() {
    this.products$=this.productService.getAllProducts();
  }

i try many solutions like this but without any result.

JSON Derulo
  • 9,780
  • 7
  • 39
  • 56
Abdellah
  • 23
  • 4

0 Answers0