import { Http } from '@angular/http' ; import { Injectable } from '@angular/core' ; import { Observable } from 'rxjs' ; import 'rxjs/add/operator/map' ; @ Injectable ( ) export class SearchWiki { constructor ( private http ) { } search ( term ) { return this . http . get ( 'https://en.wikipedia.org/w/api.php?' + 'action=query&list=search&srsearch=' + term ) . map ( ( response ) => response . json ( ) ) ; } setFoo ( value ) { return setTimeout ( ( ) => { this . foo = value ; } , 1000 ) ; } searchXML ( term ) { return this . http . get ( 'https://en.wikipedia.org/w/api.php?' + 'action=query&list=search&format=xmlfm&srsearch=' + term ) ; } }