Skip to content
Snippets Groups Projects
app.service.ts 719 B
Newer Older
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
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) {}

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  get callDeagg$(): Observable<nshmpHaz.DeaggResponse> {
    return this.http.get(this.url).pipe(
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
      map((response: nshmpHaz.DeaggResponse) => {
        if (response.status === 'error') {
          throwError(response['message']);
        }
        return response;
      })
    );
  }
}