本文整理汇总了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());
}