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