import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { throwError, Observable } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { ConfigService } from './config.service'; import { Course } from './models/course'; @Injectable() export class DataService { private plannerApiUrl: string; constructor(private http: HttpClient, private configService: ConfigService) { this.plannerApiUrl = this.configService.apiPlannerUrl; } getCourseData(): Observable<Course> { return this.http.get<Course>(this.plannerApiUrl + '/degreePlan/520224/courses') .pipe(catchError(this.errorHandler)); } private errorHandler(error: Response) { return throwError(error || 'Server Error'); } }