import { Injectable } from '@angular/core' ; import { Http , RequestOptions , URLSearchParams } from '@angular/http' ; import { Observable } from 'rxjs/Observable' ; import 'rxjs/add/operator/do' ; import 'rxjs/add/observable/empty' ; import 'rxjs/add/observable/empty' ; import { IWeatherItem } from "./IWeather" ; @ Injectable ( ) export class WeatherService { static BASE_URL : string = 'https://secure.digitalsignage.com/Weather/' ; constructor ( private http ) { } search ( query ) { function processWeather ( showToConsole ) { return ( source ) => source . do ( ( ) => { if ( showToConsole ) console . log ( `Showing weather` ) ; } ) . map ( ( e ) => { var items = e [ 0 ] . data . weather ; return items ; } ) ; } return this . http . get ( `${ WeatherService . BASE_URL }${ query }` ) . map ( ( res ) => res . json ( ) ) . let ( processWeather ( true ) ) . catch ( function ( e ) { return Observable . empty ( ) ; } ) ; } }