import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { Observable , of , BehaviorSubject } from 'rxjs' ; import { catchError } from 'rxjs/operators' ; import { environment } from '../../environments/environment' ; /**
 * Service to call http get request and get contributors data
 */ @ Injectable ( ) export class ContributorService { contributors$ = new BehaviorSubject < any > ( null ) ; constructor ( private http ) { } /**
     * Makes call to get contributors from the environment variable
     */ getContributors ( ) { const url = environment . CONTRIBUTOR_SERVICE ; this . http . get < any > ( url ) . pipe ( catchError ( this . handleError ( 'getContributors' , [ ] ) ) ) . subscribe ( response => { this . contributors$ . next ( response ) ; } ) ; } param action param result returns { any } private handleError < T > ( action , result ? ) { return ( error ) : Observable < T > => { return of ( result as T ) ; } ; } }