本文整理匯總了TypeScript中@angular/http.Jsonp.request方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Jsonp.request方法的具體用法?TypeScript Jsonp.request怎麽用?TypeScript Jsonp.request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/http.Jsonp
的用法示例。
在下文中一共展示了Jsonp.request方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getWords
getWords (limit: string): Promise<any>{
let apiUrl = 'https://wordsquiz.herokuapp.com/select';
let params = new URLSearchParams();
params.set('limit', limit);
params.set('callback', 'JSONP_CALLBACK');
return this.jsonp.request(apiUrl, {search: params}).toPromise();
}
示例2: search
search(keyword) {
return this.http.request(`http://redapesolutions.com/itunes?term=${keyword}&callback=JSONP_CALLBACK`)
.map(res => res.json())
.toPromise()
.then(data => {
return data.results
})
}
示例3: 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
}).toPromise()
.then((response) => response.json().results);
}
示例4: getPosts
getPosts(): Observable<Array<any>> {
if (this.posts) {
return Observable.of(this.posts);
}
return this.jsonp
.request('https://api.tumblr.com/v2/blog/satsukitv.tumblr.com/posts/text?callback=JSONP_CALLBACK&reblog_info=true¬es_info=true&api_key=FdXg500s7QtYKmBdk1EuFp4wGSQWWOPHnTF9bHd6gP3vrFTmQc')
.map(res => {
var posts: Array<any> = res.json().response.posts;
localStorage.setItem('blog.posts', JSON.stringify(posts));
this.posts = posts;
return this.posts;
});
}
示例5: constructor
constructor(jsonp : Jsonp) {
jsonp.request('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=JSONP_CALLBACK').subscribe(res => {
this.options = {
title : { text : 'AAPL Stock Price' },
series : [{
name : 'AAPL',
data : res.json(),
tooltip: {
valueDecimals: 2
}
}]
};
});
}
示例6: Promise
return new Promise(resolve => {
// We're using Angular Http provider to request the data,
// then on the response it'll map the JSON data to a parsed JS object.
// Next we process the data and resolve the promise with the new data.
this.jsonp.request('http://api.douban.com/v2/movie/top250')
.map(res => {
res.json();
})
.subscribe(data => {
// we've got back the raw data, now generate the core schedule data
// and save the data for later reference
this.data = data;
resolve(this.data);
});/**/
});
示例7: loadAlbuns
loadAlbuns(id) {
console.log(this.country.code);
let params = new URLSearchParams(
'callback=JSONP_CALLBACK&entity=album'
);
params.set('id', id);
params.set('country', this.country.code);
return this.jsonp.request(
'https://itunes.apple.com/lookup', {
search: params
}).toPromise()
.then((response) => response.json().results)
.then((results) => results.filter((item) => item.collectionType === 'Album'));
}
示例8: getPost
/**
* Extract the first post from the list of posts returned.
*
* @returns {Observable} path The promise to get the post data.
*/
getPost(): Observable<any> {
let url = 'http://obscurejavascript.tumblr.com/api/read/json?callback=JSONP_CALLBACK';
return this.jsonp.request(url).map(res => res.json().posts[0]);
}
示例9: getJsonp
public getJsonp(url: string, params: Object): Promise<any[]> {
return this.jsonp.request(`${url + this.prepareQueryString(params)}`)
.toPromise()
.then(this.extractData)
.catch(this.handleError);
}
示例10: getClues
getClues() {
var url = 'http://frank-designs.com/clients/sgs-beacon-hunt/beaconData.json?callback=JSONP_CALLBACK';
//var response = this.http.get(url).map(res => res.json());
// var response = this.http.get(url);
return this.jsonp.request(url).map(res => res.json());
}