Skip to content
Snippets Groups Projects
app.service.ts 747 B
Newer Older
  • Learn to ignore specific revisions
  • Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    import {HttpClient} from '@angular/common/http';
    import {Injectable} from '@angular/core';
    import {nshmpHaz} from '@ghsc/nshmp-web-utils';
    import {Observable, throwError} from 'rxjs';
    import {map} from 'rxjs/operators';
    
    
    @Injectable({
      providedIn: 'root',
    })
    export class AppService {
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      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.disaggService.DisaggResponse> {
    
        return this.http.get(this.url).pipe(
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
          map((response: nshmpHaz.disaggService.DisaggResponse) => {
    
            if (response.status === 'error') {
              throwError(response['message']);
            }
            return response;
          })
        );
      }
    }