本文整理汇总了TypeScript中@angular/http.Jsonp.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Jsonp.get方法的具体用法?TypeScript Jsonp.get怎么用?TypeScript Jsonp.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/http.Jsonp
的用法示例。
在下文中一共展示了Jsonp.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: get
get(location:string) {
var url = [
"http://api.openweathermap.org/data/2.5/weather?q=",
location,
"&APPID=57d36da6b8187a992393dc6a0f4c96c3",
"&callback=JSONP_CALLBACK"].join('')
return this.jsonp.get(url)
.map((res) => res.json())
}
示例2: searchRaw
searchRaw(term: string): Observable<string> {
let search = new URLSearchParams();
search.set('action', 'opensearch');
search.set('search', term);
search.set('format', 'json');
let response: Observable<string> = this.jsonp.get('http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK',
{ search }).map(res => res.json()[1]);
// use this to demo for a case where flatMap fails to handle out of order response
// if (term.length === 2) { return response.delay(2000); }
return response;
}
示例3: getRandomPalette
getRandomPalette():Observable<any>{
let params = new URLSearchParams();
params.set('format', 'json');
params.set('jsonCallback', 'JSONP_CALLBACK');
params.set('showPaletteWidths', '1');
return this.jsonp
.get('http://www.colourlovers.com/api/palettes/random', {search: params})
.map(this.extractData)
.catch(this.handleError);
}
示例4: submitUserData
submitUserData(data) {
const endpoint = 'http://localhost:4000/auth/facebook';
let params = new URLSearchParams();
params.set('user', data); // the user's search value
params.set('action', 'opensearch');
params.set('format', 'json');
params.set('callback', 'JSONP_CALLBACK');
console.log(data);
return this.jsonp
.get(endpoint, { search : params})
.map(res => res.json());
}
示例5: getInbound
public getInbound(stopName: string): any {
let baseUrl = 'http://realtime.mbta.com/developer/api/v2/schedulebystop';
let params = new URLSearchParams();
params.set('api_key', 'wX9NwuHnZU2ToO7GmGR9uw');
params.set('format', 'jsonp');
params.set('jsonpcallback', 'JSONP_CALLBACK');
params.set('route', 'CR-Haverhill');
params.set('stop', stopName);
params.set('max_trips', '6');
params.set('max_time', '1440');
return this.jsonp.get(baseUrl, {search: params}).map(req => req.json().mode[0].route[0].direction[1].trip);
}
示例6: getResults
getResults (name:string){
var search = new URLSearchParams();
search.set('action', "opensearch");
search.set('search', name); //replace 'ma' for variable
search.set('format', 'json');
let rs = this.jsonp
.get(
'http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK',
{ search }
)
.map(this.extractData);
console.log(rs);
return rs;
}
示例7: get
get(tag:string) {
var url = [
"http://api.flickr.com/services/feeds/photos_public.gne",
'?tags=',
tag,
'&tagmode=any',
'&format=json',
'&jsoncallback=JSONP_CALLBACK',
].join('')
return this.jsonp.get(url)
.map((res) => res.json())
}
示例8: getOutboundTrain
public getOutboundTrain(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', '6');
params.set('max_time', '1440');
return this.jsonp.get(baseUrl, {search: params}).map((req) => {
let data = req.json();
let rawOutbound = data.mode[0].route[0].direction[0].trip;
return rawOutbound.filter(this.filterByStop);
});
}
示例9: getSearchResults
// Uses jsonp.get() to load a single JSON file
getSearchResults(request: string) {
var search = new URLSearchParams();
search.set('api_key', GIANTBOMB_API_KEY);
search.set('query', request);
search.set('field_list', 'name,deck,number_of_user_reviews,site_detail_url');
search.set('limit', '10');
search.set('resources', 'game');
search.set('format', 'jsonp');
search.set('json_callback', 'JSONP_CALLBACK');
let queryUrl = `${GIANTBOMB_API_SEARCH_URL}${search}`;
this.jsonp.get(queryUrl)
.map(res => res.json())
.subscribe(data => this.data = data,
err => console.log(err),
() => console.log('Completed'));
return this.data;
}
示例10: getGameResults
getGameResults(gameID:string) {
var search = new URLSearchParams();
search.set('api_key', GIANTBOMB_API_KEY);
search.set('field_list', 'name,deck,developers');
search.set('format', 'jsonp');
search.set('json_callback', 'JSONP_CALLBACK');
gameID += "/";
let queryUrl = `${GIANTBOMB_API_GAME_URL}${gameID}${search}`;
this.jsonp.get(queryUrl)
.map(res => res.json())
.subscribe(data => this.data = data,
err => console.log(err),
() => console.log('Completed'));
// console.log(this.data + " this.data");
return this.data;
}