本文整理汇总了TypeScript中@angular/http.Jsonp类的典型用法代码示例。如果您正苦于以下问题:TypeScript Jsonp类的具体用法?TypeScript Jsonp怎么用?TypeScript Jsonp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Jsonp类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getSearchResult
getSearchResult(tagName: string):Observable<Post[]> {
let searchUrl = `https://api.instagram.com/v1/tags/${tagName}/media/recent?access_token=${localStorage.getItem('ducky_access_token')}`;
var url = searchUrl + '&callback=JSONP_CALLBACK';
return this.jsonp.get(url)
.map(this.extractData)
.catch(this.handleError);
}
示例2: getGeoDataForPostalCode
getGeoDataForPostalCode(postalCode, callback) {
var search = new URLSearchParams();
search.set('output', 'json');
search.set('q', this.pad(postalCode, 6));
search.set('client', '');
search.set('sensor', 'false');
// get address information from gothere.sg
this.jsonp.get(
'http://gothere.sg/maps/geo?callback=JSONP_CALLBACK', { search }
).map((response) => response.json()).subscribe(data => {
if (data.Status.code === 200) {
callback({
code: 200,
address: data.Placemark[0].AddressDetails.Country.Thoroughfare
.ThoroughfareName,
addressLine: data.Placemark[0].AddressDetails.Country.AddressLine, // (not all have) building, etc...
geolocation: {
lat: data.Placemark[0].Point.coordinates[1],
lng: data.Placemark[0].Point.coordinates[0]
}
})
} else {
callback({ code: 400 });
}
});
}
示例3: getOutboundBus
public getOutboundBus(route: string): any {
let baseUrl = 'http://realtime.mbta.com/developer/api/v2/schedulebyroutes';
let params = new URLSearchParams();
params.set('api_key', 'wX9NwuHnZU2ToO7GmGR9uw');
params.set('format', 'jsonp');
params.set('jsonpcallback', 'JSONP_CALLBACK');
params.set('routes', route);
params.set('max_trips', '5');
params.set('max_time', '1440');
return this.jsonp.get(baseUrl, {search: params}).map((req) => {
let routes = req.json().mode[0].route;
let data = [];
for (let myRoute of routes) {
for (let trip of myRoute.direction[0].trip){
data.push({
'route': myRoute.route_id,
'startTime': trip.stop[0].sch_dep_dt,
'startLocation': trip.stop[0].stop_name.replace(/ - Orange Line/g, '')
});
}
}
return data.sort((a, b) => a.startTime - b.startTime);
});
}
示例4: getHotMovie
getHotMovie(): Observable<any> {
return this.jsonp
.get(`https://api.douban.com/v2/book/1220562?format=json&callback=JSONP_CALLBACK`)
.map((response: Response) => {
return response.json();
});
}
示例5: searchWiki
// TODO: this would go in a service
private searchWiki(term: string): Observable<string[]> {
var params = new URLSearchParams();
params.set('action', 'opensearch');
params.set('search', term);
params.set('format', 'json');
return this._jsonp.get('http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK', { search: params })
.map((res) => res.json()[1]);
}
示例6: 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();
}
示例7: rawsearch
rawsearch(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(response => response.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})
.map((res:Response) => res.json()[1])
.catch((err:any) => Observable.throw(err));
}
示例10: getInfo
/**
* getInfo from ip-api.com jsonp, ip optional
*/
getInfo(ip?: string){
let urlService = 'http://ip-api.com/json/';
let url;
ip ? url = `${urlService}${ip}` : url = urlService;
let params = new URLSearchParams();
params.set('callback', 'JSONP_CALLBACK');
return this.jsonp
.get(url, {search: params})
.map(this.extractData);
}