Egy új importálásra is szükség van:
import { provideHttpClient } from '@angular/common/http'; //... export const appConfig: ApplicationConfig = { providers: [ provideRouter(routes), provideHttpClient() ] };
ng generate service shared/api
A konstruktorba paraméterként vegyük fel a http objektumot:
constructor(private http: HttpClient) { }
//... host = 'http://localhost:8000/api/'; //... getEmployees() { let endpoint = 'employees'; let url = this.host + endpoint; return this.http.get<any>(url); }