本文整理汇总了TypeScript中angular2/http.URLSearchParams类的典型用法代码示例。如果您正苦于以下问题:TypeScript URLSearchParams类的具体用法?TypeScript URLSearchParams怎么用?TypeScript URLSearchParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了URLSearchParams类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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);
}
示例2: makeRequest
private makeRequest(path: string){
let params = new URLSearchParams();
params.set('per_page', '100');
let url = `https://api.github.com/${path}`;
return this.http.get(url, {search: params})
.map((res) => res.json());
}
示例3: getArtistTopTracks
/**
* Get Spotify catalog information about an artistâs top tracks by country.
* @param {string} id [description]
* @param {string} country [description]
* @return {Observable<Track[]>} [description]
*/
getArtistTopTracks (id: string, country: string = 'ES'): Observable<Track[]> {
let params = new URLSearchParams();
params.set('country', country);
return this._httpSpotifyApi.get(`/artists/${id}/top-tracks`, { search: params })
.map(res => this._mapper.responseToTracks(res));
}
示例4: 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);
}
示例5: search
search (term: string) {
var search = new URLSearchParams()
search.set('text', term);
return this.http
.get('http://lararest.2ezweb.com.au/', { search })
.map((request) => request.json());
}
示例6: makeSearchRequest
private makeSearchRequest(path: string,
searchFor: string,
page: string,
perPage: string,
parameters: Map<string, any>){
let searchCriteria = this.flattenMap(parameters,
'+',
true);
console.log(searchCriteria);
let params = new URLSearchParams();
params.set('q', searchFor + '+' + searchCriteria);
params.set('page', page);
params.set('per_page', perPage);
let url = `https://api.github.com/search/${ path }`;
return this.http.get(url, {search: params})
.map((res) => res.json().items)
.do(data => {console.log('All: ' + JSON.stringify(data))})
.catch(this.handleError);
}
示例7: getData
getData(query) {
const searchParams = new URLSearchParams()
searchParams.set('name', query);
return this.http.get(this.url, {search: searchParams})
.map(res => res.json())
}
示例8: URLSearchParams
export const objToSearchParams = (obj:any):URLSearchParams => {
let params = new URLSearchParams();
for (let k in obj) {
if(obj[k]) params.append(k, obj[k]);
}
return params;
};
示例9: toParamsString
export function toParamsString(params: any) {
let urlSearchParams = new URLSearchParams();
for (let key in params) {
urlSearchParams.append(key, params[key]);
};
return urlSearchParams.toString();
}
示例10: getArtists
/**
* Get Spotify catalog information for several artists based on their Spotify IDs.
* @param {string[]} ids [description]
* @return {Observable<Artist[]>} [description]
*/
getArtists (ids: string[]): Observable<Artist[]> {
let params = new URLSearchParams();
params.set('ids', ids.join(','));
return this._httpSpotifyApi.get(`/artists`, { search: params })
.map(res => this._mapper.responseToArtists(res));
}