import { Injectable } from '@angular/core' ; import { throwError } from 'rxjs' ; import { map , catchError } from 'rxjs/operators' ; import { Sorter } from './sorter' ; @ Injectable ( ) export class DataService { url = 'https://swapi.dev/api/' ; constructor ( ) { } getFilms ( ) { } private handleError ( error ) { console . error ( 'server error:' , error ) ; if ( error . error instanceof Error ) { let errMessage = error . error . message ; return throwError ( errMessage ) ; } return throwError ( error || 'Server error' ) ; } }