My goal is to incorporate the property endpoint from my environment.ts file into my service:
export const environment = {
production: false,
endpoint: 'http://localhost:3000/api/cabin/'
};
This snippet showcases my service:
import {Injectable} from '@angular/core';
import {environment} from "../../environments/environment";
import {HttpClient} from "@angular/common/http";
import {Cabin} from "../interfaces/cabin";
import {Observable} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class CabinService {`your text`
private myAppUrl: string;
constructor(private http: HttpClient) {
this.myAppUrl = environment.endpoint;
}
getListCabins(): Observable<Cabin[]> {
return this.http.get<Cabin[]>(this.myAppUrl + '/getCabins');
}
}
Unfortunately, I am encountering an error when utilizing the service:
[ERROR] TS2339: Property 'endpoint' does not exist on type '{}'. [plugin angular-compiler]
src/app/services/cabin.service.ts:14:32:
14 │ this.myAppUrl = environment.endpoint;
What steps should I take next to resolve this issue?