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