本文整理汇总了TypeScript中angular2/http.URLSearchParams.set方法的典型用法代码示例。如果您正苦于以下问题:TypeScript URLSearchParams.set方法的具体用法?TypeScript URLSearchParams.set怎么用?TypeScript URLSearchParams.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/http.URLSearchParams
的用法示例。
在下文中一共展示了URLSearchParams.set方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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);
}
示例2: getData
getData(lat, lng) {
const searchParams = new URLSearchParams()
searchParams.set('lat', lat);
searchParams.set('lng', lng);
return this.http.get(this.url, {search: searchParams})
.map(res => res.json())
}
示例3: 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 })
.map((request) => request.json()[1]);
}
示例4: getData
getData(country, lang) {
const searchParams = new URLSearchParams()
searchParams.set('country', country);
searchParams.set('lang', lang);
return this.http.get(this.url, {search: searchParams})
.map(res => res.json())
}
示例5: checkCategoryExistence
checkCategoryExistence(parentId:string,categoryName:string){
let params:URLSearchParams = new URLSearchParams();
params.set('parentId', parentId.toString());
params.set('categoryName', categoryName.toString());
return this.http.get('/api/category/checkCategoryExistence', {
search: params
}).map(res => res.text());
}
示例6: checkUser
checkUser(username : string, password : string) : Observable<any> {
let params : URLSearchParams = new URLSearchParams();
params.set('username', username);
params.set('password', password);
return this._http.get('http://127.0.0.1:1337/user/checkLogin', {
search : params
}).map( res => res.json() );
}
示例7: loadAlbums
loadAlbums(id) {
let params = new URLSearchParams('callback=JSONP_CALLBACK&entity=album');
params.set('id', id);
params.set('country', this.setting.country.code);
return this.jsonp.request('https://itunes.apple.com/lookup', {
search: params
}).map (response => response.json().results)
.map(results => results.filter((item) => item.collectionType === 'Album'));
}
示例8: getTopScores
getTopScores() {
const endpoint = 'https://api.mlab.com/api/1/databases/angular2-puzzle/collections/score?s={"time": 1}';
const searchParams = new URLSearchParams();
searchParams.set('apiKey', API_KEY);
searchParams.set('l', "5");
return this.http
.get(endpoint, {search: searchParams})
.map(res => res.json());
}
示例9: 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]);
}
示例10: Promise
return new Promise((resolve, reject) => {
var searchParams = new URLSearchParams();
searchParams.set('imdbId', imdbId);
searchParams.set('lang', lang);
this.http.get(openSubtitlesBaseUrl, {search: searchParams}).subscribe(
res => resolve(res),
err => console.error(err)
);
});