本文整理匯總了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));
}