I have an Angular application and I\'m using JSONP as well.
This is my service:
import { Injectable } from \'@angular/core\';
import { Http, Response, He
Here is my solution:
set a variable:times
export class WikipediaService {
constructor(private jsonp: Jsonp) {
this.times=0;}
search (term: string) {
let wikiUrl = 'http://en.wikipedia.org/w/api.php';
let params = new URLSearchParams();
params.set('search', term); // the user's search value
params.set('action', 'opensearch');
params.set('format', 'json');
params.set('callback', `__ng_jsonp__.__req${this.times}.finished`);
this.times=this.times+1;
// TODO: Add error handling
return this.jsonp
.get(wikiUrl, { search: params })
.map(response => response.json()[1]);
}
}