本文整理匯總了TypeScript中angular2/http.Jsonp類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Jsonp類的具體用法?TypeScript Jsonp怎麽用?TypeScript Jsonp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Jsonp類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: lookup
lookup(symbol: string) {
let url = `http://finance.yahoo.com/webservice/v1/symbols/${symbol}/quote?format=json&view=detail&callback=JSONP_CALLBACK`;
// .catch(...)
return this._jsonp.get(url)
.map(r => +r.json().list.resources[0].resource.fields.price);
}
示例2: search
search(keyword) {
let params = new URLSearchParams('callback=JSONP_CALLBACK');
params.set('term', keyword);
return this.jsonp.request('https://itunes.apple.com/search', {
search: params
}).map(response => response.json().results);
}
示例3: searchQuotes
searchQuotes(query: string): Observable<QuoteSearch[]> {
var search: URLSearchParams = new URLSearchParams();
search.set('query', query);
return this._jsonp.get('https://s.yimg.com/aq/autoc?region=US&lang=en-US&callback=JSONP_CALLBACK', {search})
.map((response: Response) => response.json().ResultSet.Result);
}
示例4: Error
.switchMap((): Observable<any> => {
console.log("Fetching", url);
return this.jsonp
.request(url)
.timeout(15000, new Error("Timed out"))
.map((res: any) => res.json());
})
示例5: getData
getData (symbol: string) {
let year = this.date.getFullYear();
let month = this.date.getMonth() + 1;
let day = this.date.getDate();
let startDate: string = [year - 1, month, day].join("-");
let endDate: string = [year, month, day].join("-");
let apiRootYahoo = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22";
// let apiRoot = "http://marketdata.websol.barchart.com/getHistory.json";
// var params = new URLSearchParams();
// params.set('key', '2bdfab4812fc5de3327d3495356cf383');
// params.set('symbol', symbol); // the user's search value
// params.set('type', 'daily');
// params.set('startDate', '20150311000000');
// params.set('format', 'json');
// params.set('callback', 'JSONP_CALLBACK');
//
// return this._jsonp
// .get(apiRoot, { search: params })
// .map(request => request.results.json());
let fullURL = apiRootYahoo + symbol + "%22%20and%20startDate%20%3D%20%22" + startDate + "%22%20and%20endDate%20%3D%20%22" + endDate + "%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=JSONP_CALLBACK";
return this._jsonp
.get(fullURL)
.map(request => request.json());
}
示例6: URLSearchParams
loadAlbums(id) {
let params = new URLSearchParams('callback=JSONP_CALLBACK&entity=album');
params.set('id', id);
params.set('country', this.setting.country.code);
return this.jsonp.request('https://itunes.apple.com/lookup', {
search: params
}).map (response => response.json().results)
.map(results => results.filter((item) => item.collectionType === 'Album'));
}
示例7: search
search (term: string) {
var search = new URLSearchParams()
search.set('action', 'opensearch');
search.set('search', term);
search.set('format', 'json');
return this.jsonp
.get('http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK', { search })
.map((request) => request.json()[1]);
}
示例8: search
search (term: string) {
var search = new URLSearchParams()
search.set('action', 'opensearch');
search.set('search', term);
search.set('format', 'json');
return this.jsonp
.get('http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK', { search })
.toPromise() // optional to convert Observable to Promise
.then((request) => request.json()[1]);
}
示例9: search
search(term: string){
let search = new URLSearchParams();
search.set('action', 'opensearch');
search.set('search', term);
search.set('format', 'json');
return this.jsonp.get('http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK', {search})
.toPromise()
.then((res) => res.json()[1]);
}
示例10: search
search(): any {
var search = new URLSearchParams();
//search.set('action', 'opensearch');
//search.set('search', term);
//search.set('format', 'json');
//return this.jsonp.get('./showcase/portlet/data.json', { search}).map((request) => request.json()[1]);
let url = './showcase/portlet/setting.json';
return this.jsonp
.get(url, {})
.map(request => this.result(request));
}