import {HttpClient} from '@angular/common/http'; import {Injectable} from '@angular/core'; import {nshmpHaz} from '@ghsc/nshmp-utils-ts'; import {Observable, throwError} from 'rxjs'; import {map} from 'rxjs/operators'; @Injectable({ providedIn: 'root', }) export class AppService { url = 'https://earthquake.usgs.gov/nshmp-haz-ws/deagg/E2014B/COUS/-104/39/PGA/760/2475'; constructor(private http: HttpClient) {} get callDeagg$(): Observable<nshmpHaz.disaggService.DisaggResponse> { return this.http.get(this.url).pipe( map((response: nshmpHaz.disaggService.DisaggResponse) => { if (response.status === 'error') { throwError(response['message']); } return response; }) ); } }