Trotyl Yu accd74c0a2 docs(server-communication): Fix typo in example (#2199)
* docs(server-communication): Fix typo in example

Clearly we're transforming the response, not the request.

* docs(server-communication): Fix typo in example

Clearly we're transforming the response, not the request.
2016-08-26 10:12:37 -07:00

25 lines
639 B
TypeScript

// Create the query string by hand
// #docregion
import { Injectable } from '@angular/core';
import { Jsonp } from '@angular/http';
@Injectable()
export class WikipediaService {
constructor(private jsonp: Jsonp) { }
// TODO: Add error handling
search(term: string) {
let wikiUrl = 'http://en.wikipedia.org/w/api.php';
// #docregion query-string
let queryString =
`?search=${term}&action=opensearch&format=json&callback=JSONP_CALLBACK`;
return this.jsonp
.get(wikiUrl + queryString)
.map(response => <string[]> response.json()[1]);
// #enddocregion query-string
}
}