import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { map } from 'rxjs/operators'; import { nshmpHaz } from '@ghsc/nshmp-utils'; import { throwError, Observable } from 'rxjs'; @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.DeaggResponse> { return this.http.get(this.url).pipe( map((response: nshmpHaz.DeaggResponse) => { if (response.status === 'error') { throwError(response['message']); } return response; }) ); } }