src/app/providers/services/routing-lookup.service.ts
        
                            Properties | 
                    
| CustomerName | 
                                        CustomerName:         
                                     | 
                                
                                            Type :         string
                                         | 
                                    
| id | 
                                        id:         
                                     | 
                                
                                            Type :         string
                                         | 
                                    
| rtn | 
                                        rtn:         
                                     | 
                                
                                            Type :         string
                                         | 
                                    
| RTNName | 
                                        RTNName:         
                                     | 
                                
                                            Type :         string
                                         | 
                                    
| ServicingFRB | 
                                        ServicingFRB:         
                                     | 
                                
                                            Type :         string
                                         | 
                                    
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
import { catchError } from 'rxjs/operators/catchError';
import { map } from 'rxjs/operators/map';
import { SEARCH_API } from '../../app.constants';
export interface Bank {
  id: string;
  rtn: string;
  CustomerName: string;
  RTNName: string;
  ServicingFRB: string;
}
@Injectable()
export class RoutingLookupService {
  constructor(private http: HttpClient) {}
  lookup(routingNumber: string): Observable<Bank> {
    return this.http
      .get<Bank[]>(`${SEARCH_API}/routing?number=${routingNumber}`)
      .pipe(
        map(banks => banks[0]),
        catchError(error => {
          return this.handleError(error);
        })
      );
  }
  private handleError(error: HttpErrorResponse) {
    if (error.error instanceof ErrorEvent) {
      // A client-side or network error occurred. Handle it accordingly.
      console.error('An error occurred:', error.error.message);
    } else {
      // The backend returned an unsuccessful response code.
      // The response body may contain clues as to what went wrong,
      console.error(
        `Backend returned code ${error.status}, ` + `body was: ${error.error}`
      );
    }
    // return an ErrorObservable with a user-facing error message
    return new ErrorObservable(
      'Something bad happened; please try again later.'
    );
  }
}