本文整理汇总了TypeScript中@angular/common/http.HttpParams类的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpParams类的具体用法?TypeScript HttpParams怎么用?TypeScript HttpParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HttpParams类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: HttpParams
getCompetitionById$(competitionId: string,
fields: string[] = []): Observable<Competition> {
let params = new HttpParams();
if (fields.length > 0) {
params = params.set('fields', fields.join(','));
}
return this
._http
.get<Competition>(`api/competitions/${competitionId}`, {params})
;
}
示例2: list_environments
public list_environments(pretty?: boolean): Observable<Environment[]>
{
let params = new HttpParams();
if (pretty) {
params = params.set("pretty", pretty.toString());
}
let headers = new HttpHeaders();
headers = headers.set('Accept', 'application/json');
return this.http.get<Environment[]>(`${this.backend.url_for('api')}/clips/`,
{ headers: headers, params: params,
observe: 'body', responseType: 'json' }) ;
}
示例3: get_graph
public get_graph(pretty?: boolean): Observable<TransformsGraph>
{
let params = new HttpParams();
if (pretty) {
params = params.set("pretty", pretty.toString());
}
let headers = new HttpHeaders();
headers = headers.set('Accept', 'application/json');
return this.http.get<TransformsGraph>(`${this.backend.url_for('api')}/transforms/graph`,
{ headers: headers, params: params,
observe: 'body', responseType: 'json' }) ;
}
示例4: serialize
serialize(obj: any): any {
if(obj == null)
return {};
let params = new HttpParams();
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
var element = obj[key];
params = params.set(key, element);
}
}
return params;
}
示例5: getAcquisitionFrameworks
getAcquisitionFrameworks(params?: any) {
let queryString: HttpParams = new HttpParams();
if (params) {
// tslint:disable-next-line:forin
for (let key in params) {
if (params[key] !== null) {
queryString = queryString.set(key, params[key]);
}
}
}
return this._http.get<any>(`${AppConfig.API_ENDPOINT}/meta/acquisition_frameworks`, {
params: queryString
});
}
示例6: get_image
public get_image(id: string, pretty?: boolean): Observable<HttpResponse<string>>
{
if (id === null || id == undefined) {
throw new Error("Required parameter id is null or undefined (get_image)");
}
let params = new HttpParams();
if (pretty) {
params = params.set("pretty", pretty.toString());
}
let headers = new HttpHeaders();
return this.http.get(`${this.backend.url_for('api')}/images/${encodeURIComponent(String(id))}`,
{ headers: headers, params: params,
observe: 'response', responseType: 'text' }) ;
}
示例7: getFoodRegistrations
public getFoodRegistrations(fromDate: Moment = null, toDate: Moment = null, slot: number = null) {
const url = this.apiService.getApiUrl('/food-registrations');
let params = new HttpParams();
if (fromDate != null) {
params = params.append('from', this.dates.toLink(fromDate));
}
if (toDate != null) {
params = params.append('to', this.dates.toLink(toDate));
}
if (slot != null) {
params = params.append('slot', slot.toString());
}
return this.http.get<FoodRegistration[]>(url, {params}).pipe(
catchError(this.handleError)
);
}
示例8: get_config
public get_config(query?: string, pretty?: boolean): Observable<ConfigTree>
{
let params = new HttpParams();
if (query) {
params = params.set("query", query.toString());
}
if (pretty) {
params = params.set("pretty", pretty.toString());
}
let headers = new HttpHeaders();
headers = headers.set('Accept', 'application/json');
return this.http.get<ConfigTree>(`${this.backend.url_for('api')}/config`,
{ headers: headers, params: params,
observe: 'body', responseType: 'json' }) ;
}
示例9: getShellToken
getShellToken(namespace: string, podName: string): Observable<any> {
let headers = new HttpHeaders();
const username = 'publicV1'
const password = 'a1b2c3d4E'
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
headers.append('Content-Type', 'application/x-www-form-urlencoded');
const options: any = {'headers': headers};
let urlSearchParams = new HttpParams();
urlSearchParams.append('namespace', namespace);
urlSearchParams.append('podName', podName);
return this.http
.post(`/api/v1/public/shell/token`, urlSearchParams, options)
.catch(error => Observable.throw(error));
}
示例10: get_skill
public get_skill(id: string, pretty?: boolean): Observable<Skill>
{
if (id === null || id == undefined) {
throw new Error("Required parameter id is null or undefined (get_skill)");
}
let params = new HttpParams();
if (pretty) {
params = params.set("pretty", pretty.toString());
}
let headers = new HttpHeaders();
headers = headers.set('Accept', 'application/json');
return this.http.get<Skill>(`${this.backend.url_for('api')}/skiller/skills/${encodeURIComponent(String(id))}`,
{ headers: headers, params: params,
observe: 'body', responseType: 'json' }) ;
}